davethomaspilot
14th December 2012, 18:11
I've created a QTabWidget, but I can't figure out the right way to add widgets to the pages.
If I use Qt Designer, I can put a unique instance on each page of something like a List Widget by dragging them on top of each page of the QTabWidget. But, in code, I see the List Widget as "listWidget", listWidget_2, ..., instead of something like tabWidget.index(blah)->listWidget. So, it seems like the parent of the list widget isn't the tabWidget, but rather my top level widget.
I want every page to have a List Widget (and identical layout). So, I think this means I have to add the pages in my code and also create the List widgets for each new page in code. If I want to add data to one of the listwidgets, I need to find the list associated with, say ,the current page, and then add content by referencing that widget.
Is that the correct way to do it? Since pages can be added and deleted, it doesn't make sense to put widgets on the pages in Qt Designer?
Also, is there somewhere I can see what a typical use of QTabWidget looks like? Something that supports add and delete of pages and with some content on the pages, not just the tab names.
Thanks,
Dave Thomas
Added after 1 9 minutes:
Ok, I found what I need if there's only one widget on each tab, or just one of the type of interest:
http://stackoverflow.com/questions/8678684/access-the-widget-of-a-tab-in-a-qtabwidget
Works fine. I guess I"ll make sure I have only one widget if I want to be able to access it later. Otherwise, how to find it?
If I use Qt Designer, I can put a unique instance on each page of something like a List Widget by dragging them on top of each page of the QTabWidget. But, in code, I see the List Widget as "listWidget", listWidget_2, ..., instead of something like tabWidget.index(blah)->listWidget. So, it seems like the parent of the list widget isn't the tabWidget, but rather my top level widget.
I want every page to have a List Widget (and identical layout). So, I think this means I have to add the pages in my code and also create the List widgets for each new page in code. If I want to add data to one of the listwidgets, I need to find the list associated with, say ,the current page, and then add content by referencing that widget.
Is that the correct way to do it? Since pages can be added and deleted, it doesn't make sense to put widgets on the pages in Qt Designer?
Also, is there somewhere I can see what a typical use of QTabWidget looks like? Something that supports add and delete of pages and with some content on the pages, not just the tab names.
Thanks,
Dave Thomas
Added after 1 9 minutes:
Ok, I found what I need if there's only one widget on each tab, or just one of the type of interest:
http://stackoverflow.com/questions/8678684/access-the-widget-of-a-tab-in-a-qtabwidget
Works fine. I guess I"ll make sure I have only one widget if I want to be able to access it later. Otherwise, how to find it?