4 Attachment(s)
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:
Code:
void Porcupine::showPrefs()
{
qDebug("Open Prefs Window");
Preferences *prefs = new Preferences(this);
prefs.exec();
}
I get the following errors...
Code:
porcupine.cpp: In member function `void Porcupine::showPrefs()':
porcupine.cpp:257: error: no matching function for call to `Preferences::Preferences(Porcupine* const)'
preferences.h:18: note: candidates are: Preferences::Preferences(const Preferences&)
preferences.h:22: note: Preferences::Preferences()
porcupine.cpp:258: error: request for member `exec' in `prefs', which is of non-class type `Preferences*'
I know this is a classing problem, but i keep getting all messed up dealing with the autocreated H files from designer...
Thanks...
Re: Opening a Dialog from a MainWindow FileMenu
Quote:
Originally Posted by
nbkhwjm
Preferences *prefs = new Preferences(this);
There is no such constructor declared in preferences.h --- there's only Preferences::Preferences().
Quote:
Originally Posted by
nbkhwjm
prefs.exec();
prefs is a pointer, so it should be "prefs->exec();".
Re: Opening a Dialog from a MainWindow FileMenu
how should I declare this? and additional class?
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
Re: Opening a Dialog from a MainWindow FileMenu
Quote:
Originally Posted by
nbkhwjm
how should I declare this?
It should be: "Porcupine::Porcupine( QWidget *parent = 0 )".