Unsolved A nested SubClassed widget Not displayed in MdiArea - the "base" subclassed widget is displayed instead.
-
I have a MdiChild form - with a nested subclassed structure:
frmCustomer
-- frmBaseClass
--- QWidget/ class frmBaseClass : public QWidget { Q_OBJECT :: } class frmCustomer : public frmBaseClass { Q_OBJECT :: }
Loading the form from a QMainWindow
//void MainWindow::newCustomer() { frmCustomer *child = create_frmCustomer(); child->Load(); child->show(); }
//frmCustomer *MainWindow::create_frmCustomer() { frmCustomer *child = new frmCustomer; mdiArea->addSubWindow(child); return child; }
The UI controls are placed on the frmCustomer and the control's logic in the base class frmBaseClass as application forms are very similar from a controls perspective.
Why is this with Qt 5.13.0 development ID - QTCreator and VS2017.
Thanks
Tim
-
Updated Nested Class Structure -- QMdiSubWindow\frmBaseClass\frmCustomer - no change to behavior (except the child form-frmBaseClass format is changed) when it displays in the QMdiArea window.
-
Hi and welcome to devnet,
Can you show the code of these nested classes ?
-
Hello SGaist,
creating a reproducer would seem very trivial. I don't think I am doing anything unusual. When subclassing a Qt form Widget class - from another, a second level- base class, the second level base class is inherited from QMdiSubWindow. When Qt attempts to load the "top-level Qt form Widget" the second-level blank-form is displayed. This seems to be very odd behavior.
Am I missing a call to the top-level form or the MDIArea control before attempting to show the form?
-
It might be trivial but it allows everybody to work on the same code base to find out what is happening.
And from time to time, it's when writing the minimal case that you can find what's wrong.