[Qt-interest] Can an Qt Application contain 2 mainwindow?

Vincent Cai wcai at cypress.com
Thu Sep 22 12:09:57 CEST 2011


Thanks a lot.
Great article, need more time to digest for me, a newbie. :)

The conclusion is: The Qt GUI must run in main thread, right?

-----Original Message-----
From: qt-interest-bounces+wcai=cypress.com at qt.nokia.com [mailto:qt-interest-bounces+wcai=cypress.com at qt.nokia.com] On Behalf Of Samuel Gaist
Sent: 2011年9月22日 17:53
To: Qt-interest
Subject: Re: [Qt-interest] Can an Qt Application contain 2 mainwindow?

Hi,

The answer lies here:
http://doc.qt.nokia.com/4.8/thread-basics.html#gui-thread-and-worker-thread

Hope it helps
Samuel

On 22 sept. 2011, at 11:46, Vincent Cai wrote:

> Thanks.
>
> The error happens when I try to new b window in other thread.
>
> #include "TSAUtility.h"
>
> TSAUtility::TSAUtility(void) : QThread()
> {
>     DataUtt = NULL;
> }
>
> TSAUtility::~TSAUtility()
> {
>     this->terminate();
>     this->wait();
>
>     if(DataUtt)
>     {
>         delete DataUtt;
>         DataUtt = NULL;
>     }
>
>     emit SignUttClose();
> }
>
> void TSAUtility::run()
> {
>     DataUtt = new DataUtility();//failed here
>
>     DataUtt->show();
>     while(true)
>     {
>
>     }
> }
>
> Do you know why?
>
> -----Original Message-----
> From: Konstantin Tokarev [mailto:annulen at yandex.ru]
> Sent: 2011年9月22日 17:30
> To: Vincent Cai
> Cc: qt-interest at qt.nokia.com
> Subject: Re: [Qt-interest] Can an Qt Application contain 2 mainwindow?
>
> 22.09.2011, 13:28, "Vincent Cai" <wcai at cypress.com>:
> > Dear all,
> >
> >          I have and GUI application with is based on QMainwindow(a.ui).
> >
> >          And I create the other *.ui which is also based on QMainwindow(b.ui).
> >
> > When I try to open b window through menu of a window, it fail at initialization:
> >
> >         DataUtility::DataUtility(QWidget*parent):
> >
> >         QMainWindow(parent),
> >
> >         ui(newUi::DataUtility)//fail
> >
> >         {
> >
> >                 ui->setupUi(this);
> >
> > }
> >
> >          Could anybody help?
>
> Qt Application certainly can have > 1 QMainWindow. Search for bug in your code.
>
>
> --
> Regards,
> Konstantin
>
> This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest

_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest

This message and any attachments may contain Cypress (or its subsidiaries) confidential information. If it has been received in error, please advise the sender and immediately delete this message.


More information about the Qt-interest-old mailing list