Results 1 to 8 of 8

Thread: Change a TabView height following its tab child

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: Change a TabView height following its tab child

    You could check the result of getTab before calling anything on it.

    Qt Code:
    1. readonly property Tab currentTab: getTab(currentIndex)
    2. height: currentTab ? currentTab.childrenRect.height : 0
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  2. #2
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Change a TabView height following its tab child

    Thanks anda_skoa for the suggestions

    However, I noticed that it returns 0 when the tabview is loaded or when he switches the tab the first time.
    It works fine when switching tabs the second time

    To fix that I tried using Component.onCompleted, but noticed that the count of tabs is 0 when the component is created

    Here's the code to fix those problems
    Qt Code:
    1. onCountChanged:{
    2. if(count == 1){
    3. tabview.height = Qt.binding(function() {
    4. return getTab(currentIndex).childrenRect.height
    5. })
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 
    Is the code mentioned here the right way to do so or is there a more effective way to do so?

    Kindly advice

  3. #3
    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: Change a TabView height following its tab child

    It looks ok.

    Would need to experiement to see if this can be done nicer.

    Cheers,
    _

Similar Threads

  1. how to change the height of QHeaderView?
    By TorAn in forum Qt Programming
    Replies: 1
    Last Post: 13th March 2015, 08:43
  2. How to change line height in QMenu?
    By fsmoke in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2014, 05:12
  3. QTableView How to change height for all rows?
    By sergey_85 in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2009, 19:49
  4. updateEditorGeometry() and height change
    By Lykurg in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2008, 20:08
  5. Qidget height resize if child widgets invisible
    By visor_ua in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2008, 11:27

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.