Creating a Qt game with respect to GUI windows

I wanted to program a simple game with a simple graphical interface using Qt (this will be a VERY simple game, nothing unusual). I am wondering how can I create multiple windows and display them if necessary? For example, the battle screen and the inventory screen. The user should see only one of them, but should have access to the other when necessary. I used a complicated widget, but I'm not sure if this is correct. Also, is it better to design windows in the designer or encode them?

+5
source share
3 answers

StackWidget will certainly accomplish what you want to do. The reason why it is not always used for this kind of thing is because all screens are pre-created at the beginning and always exist. This means that initialization takes a little longer and you are using more resources than you need at any given time.

But, as you say, if this is a simple game, then I donโ€™t see a big problem with it. Just as easily, you can also create an empty layout and change inventory and game panels as needed.

Add your vote to everyone else suggesting using a designer. It is much easier to manipulate layouts, actions, etc., using the constructor, and then through the code.

You can see the design guide here.

So here is what I would suggest:

"battleScreen.ui" - , "inventory.ui". QWidgets QFrames, - .

"Game.ui", QMainWindow.

QStackWidget .

, ... 1) QWidget ( ) 2) QWidget . 3) "..." 4) , QWidget    :    : 5) 6) "".

, .

+4

, , , , , , . , , .

0

:

  • ; .
  • .
  • /, ; .
0

All Articles