[Qt-interest] QMainWindow centralWidget issue..
Andre Somers
andre at familiesomers.nl
Fri Jan 29 10:56:37 CET 2010
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é
More information about the Qt-interest-old
mailing list