Results 1 to 4 of 4

Thread: add items to QtabWidget

  1. #1
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default add items to QtabWidget

    ive created a QtabWidget() with 2 tabs.
    i also have a scroll area set inside a gridlayout.

    I'm trying to add the scrollarea to tab1 of the tabWidget.

    i tried using .setlayout, but that doesnt seem to work. My scroll area just sits on top of the tabs. How do I add items to Tab1?

    Qt Code:
    1. self.myTab = QTabWidget()
    2. self.tab1 = QWidget()
    3. self.tab2 = QWidget()
    4.  
    5. self.myTab.addTab(self.tab1, "TAB1")
    6. self.myTab.addTab(self.tab2, "TAB2")
    7.  
    8. self.myScrollArea = QScrollArea()
    9. self.myScrollArea_Container = QWidget()
    10. self.myScrollArea_GridLayout = QGridLayout()
    11.  
    12. self.myScrollArea_Container.setLayout(gridlayout with some stuff)
    13. self.myScrollArea.setWidget(self.myScrollArea_Container)
    14. self.myScrollArea_GridLayout.addWidget(self.myScrollArea)
    15.  
    16. self.myTab.setLayout(self.myScrollArea_GridLayout)
    To copy to clipboard, switch view to plain text mode 

    In the attached pic, you can see the issue where the scrollArea isnt inside, but sitting ontop of the tabs
    Attached Images Attached Images

  2. #2
    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: add items to QtabWidget

    You are calling setLayout on the tab widget. Why?

    Don't you want the scroll area on one of the pages?

    Cheers,
    _

  3. #3
    Join Date
    Feb 2016
    Location
    Venice, California
    Posts
    87
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: add items to QtabWidget

    I called setLayout because it seemed like the only member function that might have worked. The only other two was addtab and InsertTab, which I guess, adds more tabs. You mentioned Pages, is that what the body is called? I don't see anything in the members that seems like it will addPage, or setPageContents kinda thing. What do I use to add my scrollLayout to the tab body area?

    Thanks again

  4. #4
    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: add items to QtabWidget

    Quote Originally Posted by Nfrancisj View Post
    I called setLayout because it seemed like the only member function that might have worked.
    But it is a function on the tab widget, not on one of its tabs/pages.
    So clearly not applicable in a situation where you want to address a specific tab, right?

    Quote Originally Posted by Nfrancisj View Post
    You mentioned Pages, is that what the body is called?
    A tab widget has several pages/tabs.

    Quote Originally Posted by Nfrancisj View Post
    What do I use to add my scrollLayout to the tab body area?
    You set it on the widget that you use as the page for the respective tab.

    Or,even simpler, add the scrollarea directly as a tab.

    Cheers,
    _

Similar Threads

  1. Replies: 6
    Last Post: 21st August 2013, 13:53
  2. How to iterate through GraphicsScene items using items()
    By MercyYuen in forum Qt Programming
    Replies: 5
    Last Post: 10th October 2012, 16:51
  3. Replies: 0
    Last Post: 15th April 2011, 20:04
  4. Replies: 2
    Last Post: 20th August 2010, 06:18
  5. Replies: 1
    Last Post: 27th February 2010, 12:39

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.