PDA

View Full Version : More than one form



newToQT
30th September 2008, 13:32
Hi,

Just using designer so far and am very new to this. I have a main window form, with a menu bar. Now I have designed other forms for when one of the options on the main menu bar is triggered (i.e. an "About this application" form, a "Contact" form etc).

My problem is that I don't know how to show these forms from the main. I mean I double click on the action editor action (using VS2003 integrated with QT 4) and am brought to the app.cpp file with the action created


void protoGUIOne::on_actionProject_triggered()
{

}

Now I've tried lots of things in there to get it to show, but nothing seems to work. I've been looking around but can't find anything.

I relaise this is probably a ridicuosly easy problem but I'm a true newbie and am confused!

Any help appreciated.

spirit
30th September 2008, 14:10
when you created main form with needed actions, you should connect these action to slots and then in slots you should create (or show) needed widget.
e.g.


MyMainWindow::MyMainWindow(QWidget *parent)
: QMainWindow(parent), m_myHelp(0)
{
....
}
....
void MyMainWindow::actionHelp()
{
if (!m_myHelp)
m_myHelp = new MyHelpWidget(this);
m_myHelp->show();
}
...

this is only one variant.

newToQT
1st October 2008, 14:18
Thanks for replying. I'm still having trouble though.

I'm going through the tutorials (and am feeling really scared!) and see nothing that addresses this in a simple way. I mean I'm just starting yet but want to get this little problem fixed, I knwo it's simple!

I tried doing what you said but still got errors.

In an effort to understand I've just done up a simple program, two forms. One with a pushbutton that opens the other. Still no luck, I thought if I could get that going then any others would be easy.

Is there another way of doing it?

spirit
1st October 2008, 19:07
so, I modified your example in which you can see that there is nothing difficult of using signal and slots.

wysota
1st October 2008, 20:06
http://www.qtcentre.org/forum/faq.php?faq=qt_general_category#faq_qt_designer_2f orms

newToQT
2nd October 2008, 09:57
Thanks so much guys. You both really helped me out.