Results 1 to 9 of 9

Thread: Invoking New Dialog

  1. #1
    Join Date
    Aug 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Invoking New Dialog

    So maybe this is right under my nose but I cannot seem to figure out how to invoke a new dialog. What I want to do is have a main menu, from there the user can select a button such as "Apps" where a new dialog is displayed. This would ideally cause the main menu to be hidden or disappear when the "Apps" menu comes up. Would this be a parent - child issue? I am also not sure on how to set this up with code. Does anyone have any examples with a short explanation?



    Bryce
    CollegeARC the College Amateur Radio Club Association

  2. #2
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Invoking New Dialog

    Qt has a lot of examples (with source code). The things you need can be found there.
    I'm a rebel in the S.D.G.

  3. #3
    Join Date
    Aug 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Invoking New Dialog

    Qt has a lot of examples (with source code). The things you need can be found there.
    Yes I know. I have been reading through them as well as looking through the book C++ GUI Programming With Qt 4. However I'm not quite getting the concept. It seems as though I need to create a new class for each menu? I was trying to do a "MainMenu" class where I would have member functions such as MainMenu::Menu1, MainMenu::Menu2, etc. Now it looks as though I many need to have a new class for each menu, would this be correct?


    Bryce
    CollegeARC the College Amateur Radio Club Association

  4. #4
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Invoking New Dialog

    Ok, let's say you have a QMenuBar. If you look at this documentation, then you will see that you can easily add more menus to this menubar. One of this menu will have "Apps" item in it (after you add it).
    Hint: You can add this item with the following QMenuBar's (or QMenu's) method:
    Qt Code:
    1. QAction * addAction ( const QString & text, const QObject * receiver, const char * member );
    To copy to clipboard, switch view to plain text mode 

    when you use it for your "Apps" item you actually say "when the item with that says <text>(in your case Apps) is pressed, i want to execute <member> method, and my the way, <receiver> has this method".

    The next thing you do is implement this method which in fact does the following:
    1. Create QDialog. (or it may be already been created, it depends on your design).
    2. Show this dialog.
    I'm a rebel in the S.D.G.

  5. #5
    Join Date
    Aug 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Invoking New Dialog

    Quote Originally Posted by lyuts View Post
    Ok, let's say you have a QMenuBar. If you look at this documentation, then you will see that you can easily add more menus to this menubar. One of this menu will have "Apps" item in it (after you add it).
    Hint: You can add this item with the following QMenuBar's (or QMenu's) method:
    Qt Code:
    1. QAction * addAction ( const QString & text, const QObject * receiver, const char * member );
    To copy to clipboard, switch view to plain text mode 

    when you use it for your "Apps" item you actually say "when the item with that says <text>(in your case Apps) is pressed, i want to execute <member> method, and my the way, <receiver> has this method".

    The next thing you do is implement this method which in fact does the following:
    1. Create QDialog. (or it may be already been created, it depends on your design).
    2. Show this dialog.
    Ok and this is applicable to a QPushButton as well? That was one of my main areas of confusion when reading the sections about creating menus and toolbars the the Qt 4 book.
    CollegeARC the College Amateur Radio Club Association

  6. #6
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Invoking New Dialog

    Yes. As for this QMenuBar, you will not need QPushButton for it.
    I'm a rebel in the S.D.G.

  7. #7
    Join Date
    Aug 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Invoking New Dialog

    Quote Originally Posted by lyuts View Post
    Yes. As for this QMenuBar, you will not need QPushButton for it.
    I think I didn't explain my application very well! I want to open the new dialog by pressing a QPushButton, does this apply to it? I do not wish to have a QMenuBar.


    Thanks for the help,
    Bryce
    CollegeARC the College Amateur Radio Club Association

  8. #8
    Join Date
    May 2008
    Location
    Kyiv, Ukraine
    Posts
    418
    Thanks
    1
    Thanked 29 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Invoking New Dialog

    Oh, got it.

    Well, you will have your main window or main dialog which will have the desired QPushButton (in fact, it will be this button's parent). Besides this window/dialog will have a slot which will have the code for creating a new dialog and showing it. Connect this button's signal clicked() with your slot and that's it.
    I'm a rebel in the S.D.G.

  9. #9
    Join Date
    Aug 2009
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Invoking New Dialog

    Quote Originally Posted by lyuts View Post
    Oh, got it.

    Well, you will have your main window or main dialog which will have the desired QPushButton (in fact, it will be this button's parent). Besides this window/dialog will have a slot which will have the code for creating a new dialog and showing it. Connect this button's signal clicked() with your slot and that's it.
    Thanks for the help I'll let you know what happens. I appreciate the help.


    Bryce
    CollegeARC the College Amateur Radio Club Association

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04
  3. Replies: 9
    Last Post: 13th August 2008, 18:07
  4. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  5. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.