views:

120

answers:

2

Hi Everyone,

I am brand new to QT and need to develop the Mancala game. Since I'm brand new to the QT environment, my plan it to keep things very simple. I will be using the "Push Button" widget as pieces on the game. Since two players play this game, my idea is to have to arrays of buttons. One array for player 1 and the other for player 2. My question is since I am using "Push Button" widgets, how can I group them to iterate through? I notice that QT has both the array and vector data types but I'm confused on how these data types can be used to "group" the buttons. Does anyone know of any sample code or tutorials to look at to learn more?

Thanks for your time and any input provided.

A: 

Consider using the QButtonGroup class specifically for a group of buttons.

Generally in Qt the accepted way to have a dynamic array of things is to use the QVector class. It's a high-level class somewhat similar to STL's vector.

Eli Bendersky
Thank you, Eli. I read to learn more.
different
A: 

Don't know mancala but if it is a fixed size board are you better doing this as a grid and having the grid cells respond to a button push?

Then it's all handled by the tablewidget

Martin Beckett
Thanks for this idea. I was not aware of this widget. The game board is fixed so this could work.
different
If you eventually want something pretty then you will need to draw tiles as images - but if you are just learning about Qt this is a good place to start.
Martin Beckett