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. [Solved]Opening a New Form with new Widgets.
QtWS25 Last Chance

[Solved]Opening a New Form with new Widgets.

Scheduled Pinned Locked Moved General and Desktop
9 Posts 6 Posters 3.8k 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.
  • B Offline
    B Offline
    bmps
    wrote on last edited by
    #1

    I have built a GUI and its working. I need to put in a page where ill put in some details of the GUI and the Licenses and End User rights for the GUI. For this i have a Push Button which when clicked should open another form where i have a Text Browser and a Link which directs to the GPL 3.0 Licenses etc. But for some reason the second form is not being called when i click on it. This is the code that i have written. Please let me know where am going wrong.
    My first form where my basic GUI is created is test.ui(which has its own test.h and test.cpp). And now i have added a dialog.ui(which has a dialog.cpp and dialog.h). My pushbutton is in test.ui whiuch when called should start the dialog.ui.

    @
    void unametest::on_pushbutton_clicked()
    {
    dialog *dlg=new dialog(this);
    dlg->show();
    dlg->raise();
    dialog->activateWindow();
    }
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      [quote author="bmps" date="1321533448"]
      @
      void unametest::on_pushbutton_clicked()
      {
      dialog *dlg=new dialog(this);
      dlg->show();
      dlg->raise();
      dialog->activateWindow();
      }
      @
      [/quote]

      First, please use the right tag to mark your code.
      Second, in your code you have pointers like dlg and dialog, I suspect this is an error rewriting your code for your post. What happens if you call exec on the dialog?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bmps
        wrote on last edited by
        #3

        How do i call the exec on the dialog?? Not able to figure it out.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rokemoon
          wrote on last edited by
          #4

          [quote author="bmps" date="1321595624"]How do i call the exec on the dialog?? Not able to figure it out. [/quote]
          Here it is "exec":http://doc.qt.nokia.com/latest/qdialog.html#exec

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qxoz
            wrote on last edited by
            #5

            You can use follow:
            @void unametest::on_pushbutton_clicked()
            {
            dialog *dlg=new dialog(this);
            dlg->exec();
            }@

            or
            @void unametest::on_pushbutton_clicked()
            {
            dialog *dlg=new dialog(this);
            dlg->setWindowModality(Qt::WindowModal);
            dlg->exec();
            }@
            if you need modal window

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #6

              Sory i mean:
              @void unametest::on_pushbutton_clicked()
              {
              dialog *dlg=new dialog(this);
              dlg->setModal(true);
              dlg->exec();
              }@

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

                Doesn't calling exec() on a QDialog (-subclass) always result in a modal dialog? The setModel(true) call seems superfluous to me. You need to call show() if you want the dialog to pop up non-modally.

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

                  Andre is right. exec() on a dialog always shows it application model (default) or window modal. A call to setModel is not necessary.

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

                  1 Reply Last reply
                  0
                  • Q Offline
                    Q Offline
                    qxoz
                    wrote on last edited by
                    #9

                    Thanks, I'll remember.

                    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