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.cpp
    @
    Dialog::Dialog(QWidget parent) :QDialog(parent),ui(new Ui::Dialog)
    {
    ui->setupUi(this);
    QLabel
    newlabel = new QLabel();
    newlabel->setText("new control here");
    }

    Dialog::~Dialog()
    {
    delete ui;

    }
    @
    Dialog.h
    @
    namespace Ui {
    class Dialog;
    }

    class Dialog : public QDialog
    {
    Q_OBJECT

    public:
    explicit Dialog(QWidget *parent = 0);
    ~Dialog();

    private:
    Ui::Dialog *ui;

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



  • 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":http://doc.qt.nokia.com/latest/qdialog.html#details?



  • 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":http://developer.qt.nokia.com/doc/qt-4.7/designer-manual.html to design your user interface. The docs show you how to integrate the UI in your C++ class.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.