PDA

View Full Version : Showing different pages



Popolik
28th February 2016, 18:36
Hi,
I am lerning python and SQL by programming a small football manager game. The purpose is to learn code and not the game. Now I thought to make the GUI for the game first. However, the start is harder than expected although using the QT Designer 4.8.7.
Now to my problem. I made a new windows and put my desired menu points. Now I would like to design for every Menu point such as "Team" and for each sub menu like "Main Team" a page. And the overal goal is that if one menu point is clicked the assigned page with the content is shown. Can I do this with the menu point, or do I have to create a Tab Widget inside the Main Windows?

Kind Regards
Popolik

d_stranz
28th February 2016, 19:14
You don't really need a different "page" for each team. What you probably need to think about is having one page, but changing the contents to reflect whichever team is currently selected. If you make a unique page for each team, then it makes it very hard for you to add new teams without rebuilding your program with new page widgets, new menus, etc.

If you want to be able to load and display the information for all of the teams at the same time, then using a QTabWidget as the "central widget" for your QMainWindow class would work, but each tab should still contain an instance of the same page widget that you fill with that team's information.

If you only want the information for a single team at a time, then don't use the tab widget, simply make the page widget the central widget for the main window. Use the slots connected to the menu items to change the content of this page according to which team was selected.

anda_skoa
28th February 2016, 22:24
You can also use a QStackedWidget as the main window's central widget and then show the respective page on demand.

It is a bit like tab widget, just without visible tabs.

Cheers,
_

Popolik
29th February 2016, 18:42
Thank you both for the suggestions. Maybe I described the problem from different point of view. I thought about static webpages where contents can be reached on different pages. I do actually want one page that can be used for every team, like d_stranz proposed. I know loocked up more detail on QStackedWidget and I think this is what I am looking for. So if I design first page of the Stacked Widget than I can assign that this page is shown if "Team" is clicked, right ? And if I click "Transfer Market" than my second page will be shown with is design and contens. So if I design let's say 20 pages (for each menu and sub menu point), is this okay to do or will this make problems later when python programming will be applied?

anda_skoa
29th February 2016, 19:29
That should be ok.

Cheers,
_