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/QScrollArea unable to display widgets dinamically
Forum Updated to NodeBB v4.3 + New Features

QTabWidget/QScrollArea unable to display widgets dinamically

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 976 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.
  • Z Offline
    Z Offline
    zolidznake
    wrote on last edited by
    #1

    Hello guys,

    I am trying to add a new widget to a couple of tabs but no success.

    @QTabWidget *tt = new QTabWidget();

    for(i = serversInfo.begin(); i!= serversInfo.end(); i++){

        tt->addTab(new QScrollArea(new StandardWidget()), i.key());
    
    }@
    

    After applying this code all the tabs are empty .

    Any sugestion will be very appreciated.

    Kind Regards,
    Sil

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      The scroll area does not have a QScrollArea (widget to control) constructor but only a QScroll(parent widget) constructor. So in basic you say to the QScrollArea that his parent is StandardWidget. That is valid, because that is just a widget so capable of owning a child. Then you set that empty QScrollArea onto the tabwidet. So all works according your code!
      It should be:
      @
      QScrollArea Scroll = new ScrollArea(this) ; // or scroll = new SCrollArea();
      Scroll->setWidget(new StandardWidget); // be aware that you might loose control of the standardwidget if you do not store the pointers into class members.
      tt->addTab(Scroll, i.key()); // The tab widget does not own the widget, so no child/parent relationship. When removing tabs, the scroll widget will remain in your memory and might cause memorly leakage!
      @

      Greetz, Jeroen

      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