[Qt-interest] Howto get a nested QMainWindow shows up ?

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Wed Mar 3 09:49:48 CET 2010


Hi.

The solution is quite simple.

> void queryer::on_Connect()
> {
>     Getpass my;
>     my.show();
> }

The object my gets destroyed right after show was called. What you need
to do is to create my on the heap:

> void queryer::on_Connect()
> {
>     Getpass *my = new Getpass(this);
>     my->show();
> }

Assuming Getpass is a QWidget, my is destroyed when queryer is
destroyed.

Side note: you might want to adapt Qts code style...

Regards, Ulf


> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of Aaron Lewis
> Sent: Wednesday, March 03, 2010 8:55 AM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] Howto get a nested QMainWindow shows up ?
> 
> Forgive me for my poor english ;-)
> 
> I have a QMainWindow , and in this class , i have a function:
> 
> sample code:
> ==========================================
> void queryer::on_Connect()
> {
>     Getpass my;
>     my.show();
> }
> 
> And i put it in construct function of queryer:
> 
> queryer::queryer(QWidget *parent) :
>     QMainWindow(parent),
>     ui(new Ui::queryer)
> {
>     ui->setupUi(this);
>     setCentralWidget(ui->mainWidget);
>     on_Connect();
> }
> =========================================
> Getpass is a QMainWindow , but it doesn't show up , do i forgot
> something ?
> 
> --
> Best Regards,
> Aaron Lewis - PGP: 0xA476D2E9
> irc: A4r0n on freenode
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list