Hi, anyone can help me and tell me what is wrong with my widget application? It compiles just fine but SettingsDialog never pops up when clicking the button. Obviously there is something I don't understand here.
main.cpp
testwidget.hCode:#include "qmaemo5homescreenadaptor.h" #include "testwidget.h" #include "settingsdialog.h" #include <QtGui> int main(int argc, char *argv[]) { QApplication app(argc, argv); TestWidget w; QMaemo5HomescreenAdaptor *a = new QMaemo5HomescreenAdaptor(&w); a->setSettingsAvailable(true); QObject::connect(a, SIGNAL(settingsRequested()), &w, SLOT(showSettingsDialog())); w.show(); app.exec(); }
testwidget.cppCode:#ifndef TESTWIDGET_H #define TESTWIDGET_H #include <QtGui> class TestWidget : public QLabel { Q_OBJECT public: TestWidget(); public slots: void showSettingsDialog(); }; #endif
settingsdialog.hCode:#include "testwidget.h" #include "settingsdialog.h" #include <QtGui> TestWidget::TestWidget() : QLabel() { setText("Testing only"); } void TestWidget::showSettingsDialog() { SettingsDialog settingsWindow; settingsWindow.show(); }
settingsdialog.cppCode:#ifndef SETTINGSDIALOG_H #define SETTINGSDIALOG_H #include <QtGui> class SettingsDialog : public QDialog { Q_OBJECT public: SettingsDialog(); private: QLabel *label; QLineEdit *lineEdit; }; #endif
Thanks in advance!Code:#include "settingsdialog.h" #include <QtGui> SettingsDialog::SettingsDialog() : QDialog() { label = new QLabel(tr("Example:")); lineEdit = new QLineEdit; label->setBuddy(lineEdit); QHBoxLayout *hLayout = new QHBoxLayout; hLayout->addWidget(label); hLayout->addWidget(lineEdit); setLayout(hLayout); setWindowTitle(tr("Settings")); }

Reply With Quote

