PDA

View Full Version : Show or hide a form



Gayathri
17th November 2006, 11:30
How to show or hide a dialog from another dialog???
:)

jacek
17th November 2006, 11:34
Which Qt version do you use?

Gayathri
17th November 2006, 11:36
QT 4.1

this is the code i had written in form1.h

#include "form2.h"

void Form1::Show()
{
Form2 frm2;
frm2.show();
}

This shows the form but immediately gets closed

munna
17th November 2006, 11:39
try




void Form1::Show()
{
Form2 *frm2 = new Form2(parentOftheForm);
frm2->show();
}

jacek
17th November 2006, 11:45
QT 4.1
Then look for "C++ GUI Programming with Qt4". The Qt3 version of this book is available for download, but I'm not sure if you can download the Qt4 edition too.


This shows the form but immediately gets closed
QWidget::show() is a non-blocking call and because you create frm2 on the stack it gets destroyed as soon as it goes out of scope.

http://doc.trolltech.com/4.1/qdialog.html#return

Gayathri
17th November 2006, 11:59
Thank you guys.
Basically i am a C#.Net developer. I am new to this world. :confused:
where there is no pointer concept.
How to destroy the object created?
*frm pointer object.

jacek
17th November 2006, 12:01
How to destroy the object created?
*frm pointer object.
You can use the delete operator, but in Qt you can also set Qt::WA_DeleteOnClose widget attribute and the window will be deleted automatically as soon as it's closed.

dave
17th November 2006, 12:11
The book c++ gui programming with Qt 4.1 is also available for download under the gpl licence(I think) but without the code - just the book itself. Try googling for it.

Though in my opinion your best friend is the Qt Docs (http://doc.trolltech.com/4.2/index.html) and this forum.

Gayathri
17th November 2006, 12:11
sorry friend. how to set this attribute?

dave
17th November 2006, 12:13
http://doc.trolltech.com/4.2/qwidget.html#setAttribute

Gayathri
17th November 2006, 12:19
got things when i surfed QT docs. Thanks guys

jacek
17th November 2006, 12:39
got things when i surfed QT docs.
You should do that in the first place ;) Qt docs are really good, you just have to use them.

And it's Qt not QT.