Results 1 to 5 of 5

Thread: Custom QTabWidget loses capability to re-adjust size

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Custom QTabWidget loses capability to re-adjust size

    Ah, yes, thanks, that makes it a lot more clear.

    I suspect that the problem is setting fixed/maximum sizes, probably with too small values.

    However, I think the whole problem can be avoided by not attempting to shrink QTabWidget, but by using QTabBar and a separated QStackedWidget, combined with a suitable layout, maybe wrapped inside a custom widget.

    That way collapsing can be implemented by hiding the stacked widget, expanding should be as simple as showing it again.

    Roughly something like
    Qt Code:
    1. class ExpandTabBar : public QWidget
    2. {
    3. // add the API you would need from QTabWidget
    4. // delegate to m_tabBar and m_stackedWidget as neccessary
    5.  
    6. private:
    7. QTabBar *m_tabBar;
    8. QStackedWidget *m_stackedWidget;
    9. };
    10.  
    11. void ExpandTabBar::setCollapsed(bool collapsed)
    12. {
    13. m_stackedWidget->setVisible(!collapsed);
    14. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    remizero (21st June 2016)

  3. #2
    Join Date
    Jan 2015
    Location
    Barquisimeto, Venezuela
    Posts
    24
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Android

    Default Re: [SOLVED] Custom QTabWidget loses capability to re-adjust size

    Hi everyone again.

    After researching a lot, and consider and make several tests with the suggestion anda_skoa, I have managed to solve the problem of adjustment that I then had to "crash" area QTabWidget pages.

    The answer is somewhat simple and though the programming is inelegant, here is the left in a compressed, if someone has the same problem or something similar.

    The solution enables:
    1-. "Collapse" the page area of ​​a QTabWidget the minimum level to allow display of the tabs.
    2-. "Uncollapse" the page area of ​​restoring the pre QTabWidget "collapse" of the same dimensions.
    3-. Resize the tab area via QSplitter.
    4-. "Collapse" the page area of ​​a QTabWidget via QSplitter the minimum level to allow display of the tabs.
    5-. Even not allow "Uncollapse" via QSplitter.

    P.S.1 Something that was me all this research is that when you want to work with changing the size and / or dimensions of a widget, only work with setGeometry, instead of assigning and / or directly modify the values ​​of size, fixedSize and similar, blocking widget functionality as QSplitter convenience to make adjustments when required. Please correct me if I'm wrong.
    ****
    P.S.2 Another interesting thing also I discovered in this search is that it would be much better achieve do this in combination QDockWidget and QStackedWidget, but I failed as assign a custom QTabBar to achieve better handling of the widget to insert and to move them to any DockArea convenience.

    Thank you for all anda_skoa.
    Attached Files Attached Files
    Last edited by remizero; 21st June 2016 at 19:28.

Similar Threads

  1. Replies: 1
    Last Post: 7th May 2015, 20:58
  2. adjust table size in QDockWidget
    By jackajack01 in forum Qt Programming
    Replies: 0
    Last Post: 13th August 2012, 20:50
  3. I can not adjust the size of a widget to your content.
    By jjcarles in forum Qt Programming
    Replies: 3
    Last Post: 8th April 2010, 22:54
  4. QTabWidget adjust internal Widget to fit full size
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 25th December 2009, 01:20
  5. adjust font size to QLabel-size
    By hunsrus in forum Qt Programming
    Replies: 0
    Last Post: 9th July 2008, 14:33

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
  •  
Qt is a trademark of The Qt Company.