Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Implementing QMdiArea - no show



  • I am rebuilding my project using QMdiArea.
    I have placed my original MainWindow_CAT_TAB: as QMdiArea ->central widget.
    I can get the window title set, but no original TAB widget will show.
    Not really sure why I actually see the new title, but that is not an issue for now.

    I must have missed something, perhaps the original TAB is covered...
    I can "show " the QMdiArea without the central widget , with window title set .

    
        { // area first
            // tempoaray insert  QMdiArea test 
            QMdiArea *QMDIA = new QMdiArea();
     
            // placing MainWindow_CAT_TAB: AS CENTRAL WIDGET
            MainWindow_CAT_TAB  *mainWindow = new  MainWindow_CAT_TAB() ;
            mainWindow->setWindowTitle(" CAT  TAB orignal  now QMDI  central widget temporary ");
            mainWindow->setCentralWidget(QMDIA);
            mainWindow→show();          **NO SHOW**    	               mainWindow→centralWidget()→show();   moves QmdiArea  but no TAB show 
         //    QMDIA->show();
            return a.exec();
        }
    
    
    
    
    MainWindow_CAT_TAB::MainWindow_CAT_TAB(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow_CAT_TAB)
    {
    …
    

  • Lifetime Qt Champion

    Hi,

    What is this "original TAB" that you are mentioning ?



  • It is the main , see the definition code , and so far the only object / widget I want to add to QMdiArea.
    I think my error is - I am assuming that mainWindow->setCentralWidget is the way to do that. Apparently not.
    What confuses me - QMdiArea is a displayable widget . The attached code shows the QMdiArea and I can change its window title.

    I do not get the need for
    mainWindow->setCentralWidget

    I should be able to just add widgets , sus as my TAB widget to the QMdiArea.

    Back to RTFM ....

    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv); // runs main events
    
        {
            QMdiArea *mdiArea = new QMdiArea();
            mdiArea->show();
    
            return a.exec();
        }
    }
    


  • This works....as suspected,,,
    Why ? I need to digest that....
    ( back to setting centralWidget purpose...)

            QMdiArea *mdiArea = new QMdiArea();
            MainWindow_CAT_TAB  *mainWindow = new  MainWindow_CAT_TAB() ;
            mdiArea->addSubWindow(mainWindow);
            mdiArea->show();
    

  • Lifetime Qt Champion

    In that case your QMdiArea is a top level widget hence it has a title bar and you can set its title.

    If you use it as a "sub-widget" it will not get any decoration hence no title bar.



  • @SGaist said in Implementing QMdiArea - no show:

    In that case your QMdiArea is a top level widget hence it has a title bar and you can set its title.

    If you use it as a "sub-widget" it will not get any decoration hence no title bar.

    I am happy so far, still like to know what is the purpose of confusing me with "center widget".

    BTW the default color scheme is awful..
    ( Why do I always get stuck doing QA ?
    Yes, I had a good paying jobs doing ad-hock QA )

    Since "center widget". appears to have no effect - perhaps another "sugar"? JUST KIDDING

    I have a strange feeling I have been in QMdi before in MFC / OpenCV etc. recall "viewpoints / view-ports"...

    From exposure so far I am not sure if it is going to be better ride this time..


  • Lifetime Qt Champion

    The central widget is just literally the central widget of your QMainWindow that may also contain tool bars and dock widgets. Nothing more to it than that.

    As for the color scheme, you should post a picture so we can see however Qt uses what the system proposes unless you specify a style sheet.


Log in to reply