Reputation: 22332
So, I have a bunch of windows I want to create, each different, but has similar properties. For simplicity, lets just say I want a row of buttons along the bottom (the actual buttons differ for each window, but they should be in the same configuration). Then in the top half of the window, I want it to very based on what window is open.
In short, I would like to have window A which has the template of a window with buttons at the bottom. And then button B which instantiates the buttons, and has it's own thing at the top, and window C which has it's own set of buttons, and thing on the top, which is completely different than B.
Is there any way I can do this in Qt? Also would it be possible to just have one window A, and have it change back and forth between the configuration in B and C when appropriate?
Upvotes: 1
Views: 171
Reputation: 20725
Actually, if you know anything about QTab, then it works exactly the way you're describing, except it adds a set of tabs at the top which is probably not wanted here.
But anyway... create a QMainWindow inside which you create 3 widgets (A, B, and C). Hide B and C when using A. Then hide A and C when using B, etc.
This is similar to what Roku was proposing, but he had a somewhat different tree organization as he would only show one window and change the widgets in that larger window. Having 3 widgets that cover the entire window and switching between them is probably easier to manage as you in effect have to change only 2 of them when switching from one to the other.
Upvotes: 1
Reputation:
Yes, it can be done with Qt. You can create the widgets dynamically. Design each window as a separate QWidget which will contain other widgets (the buttons, for example). The mainwindow will then contain a simple boxlayout and one of these window widgets created dynamically. When the required window type changes, delete the current window widget and create another one.
Another option would be to put all widgets needed by windows A, B and C to same the window. When the window A is needed, show widgets belonging to it and hide the others.
Upvotes: 2