QTabWidget Question



  • Hi All,

    I've created a widget subclass and added this as a tab onto QTabWidget. My main code below.

    @
    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    Widget
    w = new Widget;
    QTabWidget* desktopUI = new QTabWidget;
    desktopUI->addTab(w, "Test");
    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addWidget(desktopUI);

    return a.exec();
    

    }
    @

    When i run this app. The app default size is half the size of my widget, i'm forced to resize it manually before i can see all widgets on the tab.
    For the life of me i cant figure out how to change the default size of the qtabwidget.

    Any ideas?

    Thanks



  • Hi MFreeM,

    what do you use the layout for?
    This should be removed.
    Aditionally, you don't call show on the top level widget.

    @
    int main(int argc, char argv[])
    {
    QApplication a(argc, argv);
    Widget
    w = new Widget;
    QTabWidget* desktopUI = new QTabWidget;
    desktopUI->addTab(w, "Test");
    desktopUI->show();

    return a.exec();
    

    }
    @



  • you don't need layout manager
    @
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);.

    Widget* w = new Widget;
    
    QTabWidget desktopUI;
    
    desktopUI.addTab(w, "Test");
    desktopUI.resize(w->size());
    desktopUI.show();
    

    // QVBoxLayout* mainLayout = new QVBoxLayout;
    // mainLayout->addWidget(desktopUI);

    return a.exec();
    

    }
    @
    [Edit:] Gerolf faster :-)



  • Oh sherbert sorry - i copied and pasted my code without thinking. This was me just playing around to see if i can try and sort the problem.

    But i see rokemoon has helped with the size problem..

    I'll try that - thanks!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.