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. (Beginner) How do I summon this dialog?
QtWS25 Last Chance

(Beginner) How do I summon this dialog?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.4k 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.
  • D Offline
    D Offline
    DanielDrake
    wrote on last edited by
    #1

    There's a fundamental concept here I'm not grasping :(

    I'm trying to create a simple address book. The "add contact" button will run the appropriate function, but I can't figure out what to put in that function in order to summon the addcontact.ui I created.

    I have a feeling the answer will be long, so I appreciate in advance the time you may take to answer :)

    Files I have:
    ui/mainwindow.ui
    ui/addcontact.ui
    src/mainwindowimpl.h
    src/mainwindowimpl.cpp
    src/main.cpp

    MainWindowImpl.cpp:
    @#include "mainwindowimpl.h"

    MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
    : QMainWindow(parent, f)
    {
    setupUi(this);
    connect(actionNew_Conact, SIGNAL(activated()),
    this, SLOT(addcontact()));
    }
    void MainWindowImpl::addcontact()
    {
    // this function will run when the button is pressed
    // this function should summon the "add client" dialog
    }@

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vinb
      wrote on last edited by
      #2

      if you want to 'summon' the dialog you have to:

      1. make a class wich handles the addcontact ui.
      2. include the header from your addcontact class.
      3. call it to show with : .exec or .show.

      If you use creator for making your addcontact ui, just add a 'Qt designer form class' and you have it all at once.

      edit:
      if you make your ui in designer and later on add a handling class to it, you have to include the ui_addcontact.h manualy.
      Look at "this":http://doc.qt.nokia.com/4.7/designer-manual.html for more info about using designer.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DanielDrake
        wrote on last edited by
        #3

        I use QDevelop and the Qt Designer and included the automatically generated "ui_addcontact.h".

        The class name seems to be Ui_dialogAddContact. Could you show me an example of what the function code would look like? I can't seem to get it to compile even with the inclusion.

        Thank you :)

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #4

          You really should read the link i gave you, but here is a little example:
          @
          #include <QApplication>
          #include <QDialog>
          #include "ui_dialogAddContact.h"

          int main(int argc, char *argv[])
          {
          QApplication app(argc, argv);
          Ui::dialogAddContact ui;
          QDialog *dialog = new QDialog;
          ui.setupUi(dialog);
          dialog->show();
          return app.exec();
          }
          @
          this will only shows your dialog, without any handling class behind it. look at your mainwindow class how to make a handling class for it. :)

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DanielDrake
            wrote on last edited by
            #5

            Solved!

            You are a gentleman and a scholar.

            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