PDA

View Full Version : add items to QtabWidget



Nfrancisj
1st July 2016, 01:47
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?


self.myTab = QTabWidget()
self.tab1 = QWidget()
self.tab2 = QWidget()

self.myTab.addTab(self.tab1, "TAB1")
self.myTab.addTab(self.tab2, "TAB2")

self.myScrollArea = QScrollArea()
self.myScrollArea_Container = QWidget()
self.myScrollArea_GridLayout = QGridLayout()

self.myScrollArea_Container.setLayout(gridlayout with some stuff)
self.myScrollArea.setWidget(self.myScrollArea_Cont ainer)
self.myScrollArea_GridLayout.addWidget(self.myScro llArea)

self.myTab.setLayout(self.myScrollArea_GridLayout)


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

anda_skoa
1st July 2016, 08:24
You are calling setLayout on the tab widget. Why?

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

Cheers,
_

Nfrancisj
1st July 2016, 08:43
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

anda_skoa
1st July 2016, 14:09
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?



You mentioned Pages, is that what the body is called?

A tab widget has several pages/tabs.



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,
_