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. Re-layout-ing in a subclass
Forum Updated to NodeBB v4.3 + New Features

Re-layout-ing in a subclass

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 688 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.
  • D Offline
    D Offline
    Daniel T
    wrote on last edited by
    #1

    Hi my friends.
    I have a question. I have a class, named Base which is a QDialog, and this have a very heavy population of widgets and established connection. It is possible to create a subclass of Base, called "Derived", which use all this created widgets of Base, and only make global changes of structure of layout of Base, and also add some other widgets ?
    In other words, it is possible, to use Base created widgets, and simply re-layout it ? I read about that we cannot set 2 times "setLayout" if we not delete previously layout, So if i delete a layout, it will also delete his containing widgets ?
    Greatings and thanks for any help.
    Daniel

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Yes you can re-layout but layout owns the widget so you must take them out before you remove layout
      something like.

      void RemoveLayout (QWidget* widget)
      {
          QLayout* layout = widget->layout ();
          if (layout != 0)
          {
          QLayoutItem *item;
          while ((item = layout->takeAt(0)) != 0)
              layout->removeItem (item);
          // keep or add to other layout
          delete layout;
          }
      }
      
      1 Reply Last reply
      0
      • D Offline
        D Offline
        Daniel T
        wrote on last edited by
        #3

        Thanks.
        It is exactly what i need to know.
        Daniel

        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