Results 1 to 8 of 8

Thread: Qt show modal dialog (.ui) on menu item click

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Posts
    6
    Thanks
    2

    Default Re: Qt show modal dialog (.ui) on menu item click

    Qt Code:
    1. void MainWindow::get_started_info()
    2. {
    3. QMessageBox::information(this,"About","message");// dont forget to include QMessageBox
    4. }
    To copy to clipboard, switch view to plain text mode 
    this works, when I click on Get Started, this message box appears

    Qt Code:
    1. get_started *one; //in your mainwindow under private
    To copy to clipboard, switch view to plain text mode 
    like this :
    Qt Code:
    1. private:
    2. Ui::MainWindow *ui;
    3. //! Create the menu classes
    4. void createActions();
    5. void createMenus();
    6. //! Menu Items
    7. QMenu *home;
    8. QMenu *help;
    9. QAction *quit;
    10. QAction *start;
    11. QAction *about;
    12. get_started *one;
    To copy to clipboard, switch view to plain text mode 
    but I get an error 'get_started' does not name a type

  2. #2
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt show modal dialog (.ui) on menu item click

    Quote Originally Posted by tomorrow
    but I get an error 'get_started' does not name a type
    Did you include get_started.h ?
    And you have
    Qt Code:
    1. #include "ui_get_started.h"
    To copy to clipboard, switch view to plain text mode 
    I am not sure if you need this to be included in both header and cpp file, maybe just in your .cpp file.

    Good Luck.

  3. The following user says thank you to toufic.dbouk for this useful post:

    tomorrow (15th November 2013)

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt show modal dialog (.ui) on menu item click

    The original code was almost correct, the only mistake was usign qApp as the receiver object instead of this.

    Creating the dialog on the stack and excuting it as a modal dialog using exec() where correct.

    Cheers,
    _

  5. #4
    Join Date
    Dec 2012
    Posts
    197
    Thanks
    25
    Thanked 41 Times in 33 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt show modal dialog (.ui) on menu item click

    Quote Originally Posted by anda_skoa
    Creating the dialog on the stack and excuting it as a modal dialog using exec() where correct.
    Yes it was correct and we mentioned that he can keep his code since its right instead of creating it on heap. Creating it on the stack will limit the scope where you can use the object for further usage.

Similar Threads

  1. Replies: 2
    Last Post: 11th May 2012, 10:38
  2. Right-Click menu on a pushButton doesn't show up
    By qtpyqt in forum Qt Programming
    Replies: 6
    Last Post: 9th September 2010, 17:58
  3. How to edit view item with a modal dialog?
    By e79ene in forum Newbie
    Replies: 1
    Last Post: 26th March 2010, 15:57
  4. Need to show a menu item with disabled look but functional
    By lalesculiviu in forum Qt Programming
    Replies: 4
    Last Post: 21st October 2009, 15:16
  5. Replies: 0
    Last Post: 29th July 2009, 19:13

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
  •  
Qt is a trademark of The Qt Company.