Results 1 to 5 of 5

Thread: Opening a Dialog from a MainWindow FileMenu

  1. #1
    Join Date
    Mar 2007
    Posts
    59
    Thanks
    7

    Default Opening a Dialog from a MainWindow FileMenu

    All I have created a MainWindow Application Called "porcupine" This has a File menu where you *should* be able to open a QDialog (preferences.ui) file to set the application preferences.

    I set the Signals and Slots to point to a Function:

    Qt Code:
    1. void Porcupine::showPrefs()
    2. {
    3.  
    4. qDebug("Open Prefs Window");
    5.  
    6. Preferences *prefs = new Preferences(this);
    7. prefs.exec();
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    I get the following errors...

    Qt Code:
    1. porcupine.cpp: In member function `void Porcupine::showPrefs()':
    2. porcupine.cpp:257: error: no matching function for call to `Preferences::Preferences(Porcupine* const)'
    3. preferences.h:18: note: candidates are: Preferences::Preferences(const Preferences&)
    4. preferences.h:22: note: Preferences::Preferences()
    5. porcupine.cpp:258: error: request for member `exec' in `prefs', which is of non-class type `Preferences*'
    To copy to clipboard, switch view to plain text mode 

    I know this is a classing problem, but i keep getting all messed up dealing with the autocreated H files from designer...

    Thanks...
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening a Dialog from a MainWindow FileMenu

    Quote Originally Posted by nbkhwjm View Post
    Preferences *prefs = new Preferences(this);
    There is no such constructor declared in preferences.h --- there's only Preferences::Preferences().

    Quote Originally Posted by nbkhwjm View Post
    prefs.exec();
    prefs is a pointer, so it should be "prefs->exec();".

  3. #3
    Join Date
    Mar 2007
    Posts
    59
    Thanks
    7

    Default Re: Opening a Dialog from a MainWindow FileMenu

    how should I declare this? and additional class?

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening a Dialog from a MainWindow FileMenu

    1. You should use an additional class for your dialog, not the main window class.
    2. The ui_porcupine.h file is automatically generated by the uic ( UI compiler ). All you have to do is include it in your dialog header. You must not modify/or care about this file, because it will be overwritten each time you modify something in the ui.

    To show it using a menu, I think you first should read the Menus example in the Main Windows section from the examples and demos. This should help you a bit.

    Also, have a look at the Qt Designer manual ( int the Assistant ).

    BTW: what is a porcupine?
    Edit - nevermind . I know now, but it sounds so funny...


    Regards
    Last edited by marcel; 17th April 2007 at 06:26.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Opening a Dialog from a MainWindow FileMenu

    Quote Originally Posted by nbkhwjm View Post
    how should I declare this?
    It should be: "Porcupine::Porcupine( QWidget *parent = 0 )".

Similar Threads

  1. Replies: 1
    Last Post: 1st February 2007, 18:07
  2. Replies: 3
    Last Post: 23rd July 2006, 19:02
  3. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 09:22
  4. Dialog positioning in GNOME
    By simk in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 10:41
  5. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 15:52

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.