Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MainWindow to new Dialog window connection/calling
QtWS25 Last Chance

MainWindow to new Dialog window connection/calling

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 4.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    petergeng
    wrote on last edited by
    #1

    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();
    @
    ?????

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        petergeng
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            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.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved