Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need <a href="http://doc.qt.io/archives/4.6/signalsandslots.html" rel="nofollow noreferrer">signals and slots.</a></p> <p>You have to connect the clicked signal to a custom slot, created by you, of your main widget.</p> <p><strong>Corrected Code, based in the comments of <a href="https://stackoverflow.com/users/178488/patrice-bernassola">Patrice Bernassola</a> and <a href="https://stackoverflow.com/users/248066/job">Job</a>.</strong></p> <p>In the class definition (.h file) add the lines:</p> <pre><code>Q_OBJECT private slots: void exampleButtonClicked(); private: QDialog *exampleDialog; </code></pre> <p>The macro Q_OBJECT is needed when you define signals or slots in your classes.</p> <p>The variable exampleDialog should be declared in the definition file to have access to it in the slot.</p> <p>And you have to initialize it, this is commonly done in the constructor</p> <pre><code>ExampleClass::ExampleClass() { //Setup you UI dialog = new QDialog; } </code></pre> <p>In the class implementation (.cpp file) add the code that does what you want, in this case create a new window.</p> <pre><code>void ExampleClass::exampleButtonClicked() { exampleDialog-&gt;show(); } </code></pre> <p>And also you have to connect the signal to the slot with the line:</p> <pre><code>connect(exampleButton, SIGNAL(clicked()), this, SLOT(exampleButtonClicked())); </code></pre> <p>Your question is somehwat basic, so I suggest to read a basic tutorial, in this way you can make progress faster, avoiding waiting for answers. Some links to tutorials that were useful to me:</p> <p><a href="http://zetcode.com/tutorials/qt4tutorial/" rel="nofollow noreferrer">http://zetcode.com/tutorials/qt4tutorial/</a></p> <p><a href="http://doc.qt.io/archives/qt-4.7/tutorials-addressbook.html" rel="nofollow noreferrer">http://doc.qt.io/archives/qt-4.7/tutorials-addressbook.html</a></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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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