Note that there are some explanatory texts on larger screens.

plurals
  1. POGUI programming with Qt custom dialog
    primarykey
    data
    text
    <p>I'm new with Qt and having some playing-around with it. </p> <p>I picked a sample code from "C GUI programming with Qt 4" and cannot find anything incomprehensive about the code but it doesn't run correctly: </p> <p>** projectfile.pro</p> <pre><code>QT += core gui TARGET = CustomDialog TEMPLATE = app SOURCES += main.cpp \ finddialog.cpp HEADERS += \ finddialog.h </code></pre> <p>** dialog header: </p> <pre><code>#ifndef FINDDIALOG_H #define FINDDIALOG_H #include &lt;QDialog&gt; class QCheckBox; class QLabel; class QLineEdit; class QPushButton; class FindDialog : public QDialog { Q_OBJECT public: FindDialog(QWidget *parent = 0); signals: void findNext(const QString &amp;str, Qt::CaseSensitivity cs); void findPrevious(const QString &amp;str, Qt::CaseSensitivity cs); private slots: void findClicked(); void enableFindButton(const QString &amp;text); private: QLabel *label; QLineEdit *lineEdit; QCheckBox *caseCheckBox; QCheckBox *backwardCheckBox; QPushButton *findButton; QPushButton *closeButton; }; #endif // FINDDIALOG_H </code></pre> <p>** dialog cpp: </p> <pre><code>#include &lt;QtGui&gt; #include "finddialog.h" FindDialog::FindDialog(QWidget *parent) : QDialog(parent) { label = new QLabel(tr("Find &amp;what:")); lineEdit = new QLineEdit; label-&gt;setBuddy(lineEdit); caseCheckBox = new QCheckBox(tr("Match &amp;case")); backwardCheckBox = new QCheckBox(tr("Search &amp;backward")); findButton = new QPushButton(tr("&amp;Find")); findButton-&gt;setDefault(true); connect(lineEdit, SIGNAL(textChanged(const QString &amp;)), this, SLOT(enableFindButton(const QString &amp;))); connect(findButton, SIGNAL(clicked()), this, SLOT(findClicked())); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *topLeftLayout = new QHBoxLayout; topLeftLayout-&gt;addWidget(label); topLeftLayout-&gt;addWidget(lineEdit); QVBoxLayout *leftLayout = new QVBoxLayout; leftLayout-&gt;addLayout(topLeftLayout); leftLayout-&gt;addWidget(caseCheckBox); leftLayout-&gt;addWidget(backwardCheckBox); QVBoxLayout *rightLayout = new QVBoxLayout; rightLayout-&gt;addWidget(findButton); rightLayout-&gt;addWidget(closeButton); rightLayout-&gt;addStretch(); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout-&gt;addLayout(leftLayout); mainLayout-&gt;addLayout(rightLayout); setLayout(mainLayout); setWindowTitle(tr("Find")); setFixedHeight(sizeHint().height()); } void FindDialog::findClicked() { QString text = lineEdit-&gt;text(); Qt::CaseSensitivity cs = caseCheckBox-&gt;isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive; if (backwardCheckBox-&gt;isChecked()) { emit findPrevious(text, cs); } else { emit findNext(text, cs); } } void FindDialog::enableFindButton(const QString &amp;text) { findButton-&gt;setEnabled(!text.isEmpty()); } </code></pre> <p>** main.cpp: </p> <pre><code>#include &lt;QtGui/QApplication&gt; #include "finddialog.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); FindDialog w; w.show(); return a.exec(); } </code></pre> <p>what's wrong here?? </p> <p>when I click run, no dialog is shown but this error:</p> <p><img src="https://i.stack.imgur.com/sRCfd.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload