MainWindow to new Dialog window connection/calling

  • so i have a mainwindow setup, and a right click control. Once of the the options of the right click is activated, the mainwindow script opens up a new dialog window.

    now i want to add controls and goodies and things to this new dialog window and i want it to be on a separate .h and .cpp file, basically its own dialog class. thesefore it'll be easier for me to edit and add things to this new dialog window.

    how would i go about doing this?
    here is what i have so far
    Dialog::Dialog(QWidget parent) :QDialog(parent),ui(new Ui::Dialog)
    newlabel = new QLabel();
    newlabel->setText("new control here");

    delete ui;

    namespace Ui {
    class Dialog;

    class Dialog : public QDialog

    explicit Dialog(QWidget *parent = 0);

    Ui::Dialog *ui;

    how do i declare a dialog class in mainwindow? here what i have in mainwindow
    Dialog* dia = new Dialog();

  • So - what is your question or problem (besides the fact that newlabel won't be shown as expected as it is not part of any layout set for the dialog)?

    Have you read the documentation on "QDialog":

  • how do I bind elements to the Dialog? for example how do I make this newlabel show? or add other textbox/checkbox and etc...

  • Please search the archives. This question is asked over and over and over again.

  • You can use "Qt Designer": to design your user interface. The docs show you how to integrate the UI in your C++ class.

Log in to reply