السلام عليكم و رحمة الله و بركاته
انا حاليا اتعلم مكتبة Qt لعمل برامج GUI و قد اخترت Qt تبعا لنصيحة الكثير اولهم اختى العزيزة رغد .
ندخل فى الموضوع , انا اعمل على برنامج قمة فى البساطة , فكرته فى انى عندما ادوس على زر QPushButton يتم كتابة نص معين فى صندوق نصى QLineEdit
هذا هو الكود :
- #include <QApplication>
- #include <QWidget>
- #include <QtGui>
- class Connection : public QWidget
- {
- public:
- Connection();
- private:
- QLineEdit* lineEdit;
- QPushButton* bt;
- QWidget* window;
- QHBoxLayout* layout;
- };
- int main(int argc, char* argv[])
- {
- QApplication app(argc, argv);
- Connection *conn = new Connection;
- return app.exec();
- }
- Connection::Connection()
- {
- window = new QWidget;
- lineEdit = new QLineEdit;
- bt = new QPushButton("Make Connection");
- layout = new QHBoxLayout;
- QObject::connect(bt, SIGNAL(clicked()), lineEdit, SLOT(setText("Omar")));
- layout->addWidget(bt);
- layout->addWidget(lineEdit);
- window->setWindowTitle("Connection");
- window->setLayout(layout);
- window->show();
- }
المشكلة فى سطر جملة connect
- QObject::connect(bt, SIGNAL(clicked()), lineEdit, SLOT(setText("Omar")));
انا انشئت connection بين QPushButton اسمه bt و QLineEdit اسمه lineEdit وفعندما يتم الضغط على الزر bt يتم تنفيذ setText
و لكن المشكلة انه لا يتم التنفيذ فالبرنامج يعمل بدون اى مشاكل لكن الكود لا ينفذ .
استعنت بـ Qt Assistant و لكن لا جدوى .
فما هى المشكلة ؟ اتمنى ان نجد الحل سويا