[Qt-interest] Fwd: QMainWindow centralWidget issue..
Nikos Gerontidis
geronik444 at gmail.com
Fri Jan 29 11:23:11 CET 2010
---------- Forwarded message ----------
From: Andre Somers <andre at familiesomers.nl>
Date: Fri, Jan 29, 2010 at 11:56 AM
Subject: Re: [Qt-interest] QMainWindow centralWidget issue..
To: Qt-interest <qt-interest at trolltech.com>
Nikos Gerontidis wrote:
> Hi list,
>
> I create 2 widgets and /append/ them in a /QList/ object,
How? I hope you're creating them on the heap, right? Not on the stack?
> which is a member of
> my /CustomMainWindow/ class. While in run time, I set the central widget
> with the /setCentralWidget(QWidget*)/ function. My application crashes
> when I
> set twice the same widget as a central widget.
>
> Is it a problem related to the fact that QMainWindow takes ownership
> of the widget, when this widget is being set as a central widget.
> Any ideas? Thanks in advance.
Are you sure your widget still exists when you set it again? Put a
breakpoint in the destructor of your widget, or generate some debut
output there to check.
The question is of course, why are you changing what widget is the
central widget in the first place? Would a QStackedWidget not be a
better candidate to manage what's visisble in your application?
André
Thank you for your instant responses..
Before setting a new widget in the *on_setNewWidget *function
I check if pWidget is NULL with
*QWidget *pWidget = listOfCentralWidgets.at(0); // this is the list containg
the cetral* widgets
*if (pWidget)
setCentralWidget(pointerToAnotherWidget);*
the if statement passes normally and then the application crashes..
It is strange at the moment. I ll debug it and check it better.
I will use the QStackedWidget, which I believe is a solution to my issue.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
--
Best Regards
Nikos Gerontidis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100129/706ef4d4/attachment.html
More information about the Qt-interest-old
mailing list