Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTabWidget Question
Qt 6.11 is out! See what's new in the release blog

QTabWidget Question

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MFreeM
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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();
      

      }
      @

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rokemoon
        wrote on last edited by
        #3

        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 :-)

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MFreeM
          wrote on last edited by
          #4

          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!!

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved