I am brand new to Qt and need to develop the Mancala game. Since I'm开发者_如何学C 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.
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
.
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
精彩评论