Results 1 to 8 of 8

Thread: QTabWidget: How to add a layout to a tab?

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60 Maemo/MeeGo

    Question QTabWidget: How to add a layout to a tab?

    Hello everybody,

    there exist any way to add a layout to a tab? something like as shown in this link:

    http://doc.trolltech.com/4.4/designe...ontainers.html

    I think that in qt4.5 this feature was broken (in qt-designer), but maybe I'm wrong.

    The only way in which I can add a layout to a tab is create a tab (in qt-designer) and then edit manually this tab by adding

    <layout class="QGridLayout" name="gridLayout">
    </layout>

    but this sucks,

    regards,
    flipflop

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabWidget: How to add a layout to a tab?

    What is/was broken? QTabWidget is in no way different than other widgets. Everything works as expected.
    Attached Files Attached Files
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2011
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Symbian S60 Maemo/MeeGo

    Default Re: QTabWidget: How to add a layout to a tab?

    Quote Originally Posted by wysota View Post
    What is/was broken? QTabWidget is in no way different than other widgets. Everything works as expected.
    Hi wysota, thanks for your response, could you see this video explanation? :

    http://www.youtube.com/watch?v=8JYEdXDhrTY

    in this video you can see the problem and a way to avoid it, but the problem still remains, the problem is that you can't add a layout to a tab without any widget, if you add a widget (a QGridLayout for example, like in this video) then everything works fine,

    regards,
    flipflop
    Last edited by flipflop; 12th May 2011 at 21:23. Reason: updated contents

  4. The following user says thank you to flipflop for this useful post:

    frankiefrank (2nd May 2014)

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTabWidget: How to add a layout to a tab?

    Again, QTabWidget is by no means different than any other widget. If you create a plain QWidget, layouting options will also be disabled because there is nothing to manage by the layout. That's a logical and expected behaviour.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Oct 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTabWidget: How to add a layout to a tab?

    I came here wondering about the same thing.

    I think what wysota is trying to say, but can't help but be a dïck about it, is that you need to add one or more widgets into the QTabWidget (or QGroupBox) before you can set the layout by right-clicking and opening the context menu.

    Not really one of the most intuitive features of the form designer.

  7. #6
    Join Date
    Mar 2013
    Posts
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QTabWidget: How to add a layout to a tab?

    In designer You should first in form preview select requested tab, than in tree-view click to PARENT QTabWidget and set the layout as for all tabs. Really this layout appears as new properties for selected tab only. Every tab has own layout.
    Last edited by vmlich; 13th March 2013 at 12:31.

  8. #7
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: QTabWidget: How to add a layout to a tab?

    Quote Originally Posted by Zaph View Post
    I came here wondering about the same thing.

    I think what wysota is trying to say, but can't help but be a dïck about it
    Is that necessary?

  9. #8
    Join Date
    Jun 2017
    Posts
    2
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget: How to add a layout to a tab?

    setCurrentIndex method of QTabWidget class takes a QWidget object as an argument so:
    all you have to do is create a new QWidget object and use the setLayout method to set your layout to that object:
    yourLayout = QVBoxLayout() #or whatever else
    w = QWidget()
    w.setLayout( yourLayout )
    addTab(w)

Similar Threads

  1. Replies: 6
    Last Post: 21st August 2013, 13:53
  2. Qt Designer Solved: Adding widgets to QTabWidget layout
    By koan in forum Qt Tools
    Replies: 1
    Last Post: 14th February 2011, 00:35
  3. Replies: 0
    Last Post: 12th December 2010, 06:09
  4. Replies: 0
    Last Post: 25th May 2009, 11:00
  5. Replies: 7
    Last Post: 15th June 2007, 17:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.