[Qt-interest] Bizarre undefined behaviour with UI generated classes
John Moran
johnfrederickmoran at gmail.com
Sat Nov 28 16:07:00 CET 2009
Hello,
I've written a class that manages resources (QWidgets that represent
pages of a QStackedWidget, and their associated UI classes) and makes
them pages of a QStackedWidget that it also manages.
I'm experiencing bizarre undefined behaviour:
// client code, within main widget that is the "parent" (not parent,
but parent of its widgets) of the resource managing class:
mymainscreen.setupUi(this); // mymainscreen is my resource managing
class; Not actually UI generated, but based on a UI generated class
// *Doesn't* appear to be problematic, despite being more or less
identical to code below
mymainscreen.working_page->OtherTree->setSelectionBehavior(QAbstractItemView::SelectRows);
// consistenly causes UB (debugger locks):
mymainscreen.options_page->SalesTree->setSelectionBehavior(QAbstractItemView::SelectRows);
When I do something that ought to be exactly equivalent to the call to
.options_page->SalesTree->setSelectionBehavior() above within the
resource managing class itself:
// set up options
options_widget = new QWidget(MainScreen);
options_page = new Ui::Options;
options_page->setupUi(options_widget);
stackedWidget->addWidget(options_widget);
// try and re-create problem here (cannot):
options_page->SalesTree->setSelectionBehavior(QAbstractItemView::SelectRows);
It works! this, despite the fact that we don't touch the
options_page/SalesTree ptrs again within our resource managing class,
and despite the fact that essentially the same thing consistently
works elsewhere!
What might be in play here? What should I do?
Regards,
John Moran
More information about the Qt-interest-old
mailing list