Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to make a Monopoly board with Qt



  • Hey all,

    I'm new to QT and have read up on the basics. I am trying to create monopoly using QT so that players can move their pieces across spaces. So my question is this: Would this be too advanced to create with someone like me who just started using QT 2 days ago and knows only the basics--I just know how to create toolbars, menus, and stuff related to mainwindow--as I don't want to waste too much time since it is a school project? Thanks.


  • Moderators

    It's a great opportunity to learn, although it does sound a bit more advanced. Take a look at QtQuick and QML, it should be easy to learn and implement your project using that technology.



  • Thanks for the reply and answer to my question! I only have a short time frame of about a week so do you think it's doable within that amount of time?


  • Moderators

    No, I do not think so. That is too short even for an expert (well, depending on how advanced you want the game to be, and whether you care about code quality, of course).



  • The thing is I already have the entire code of the game done as I coded it with Visual Studio 2012 and made the game play on the command line with an actual board and etc. But like you said, I find it highly unreasonable to create a GOOD quality game with Qt in under a week given that I am new to Qt; so am I right in making this assumption? I feel the most I could do with the knowledge I have now is just post a picture of the monopoly board as a central widget then have the player pieces adjust their position on the board with setGeometry after each move. Thanks again.


  • Moderators

    That might do for a hacky solution, yes ;-)



  • Okay cool :)

    So quick question: what's the definition of a widget in Qt? And what would be the best way to implement the idea I just thought of in the above post? I'm thinking a mainwindow with a central widget as the board, and player class as a widget, and have the setGeometry just update after each move. Which widget would be best to display text and actions at the bottom of a board that a player can input and get output from in the form of text? Thanks so much!


  • Moderators

    Use QLabel to display text and images.
    Use QLineEdit to get user input.
    Use QPushButton if you need a button.



  • Awesome thanks so much!! :)

    So I'm thinking of this:

    • Create a class called Game_Board which inherits from MainWindow and will contain menus, the central widget which will be an image of the monopoly board, and player widgets. Then I'll just implement the actual code of the game to be displayed to the user with QLineEdit(getting user input) and QLabel(displaying text of the game) and QPushButton(rolling the dice, starting the game, ending the game, etc) so am I on the right track? thanks again man you've helped me alot!!

  • Moderators

    Looks about right. Start coding and when more questions spring up, feel free to ask here.

    BTW: to make the UI automatically respond to changes, use layouts (QLayout: grid, form, horizontal, vertical).



  • Will do man, thanks again for all your help!

    I know what layouts are but I didn't understand why we would need to use them "to make the UI automatically respond to changes?" Thanks again.


  • Moderators

    Sorry, I should have elaborated. When you use layouts, Qt will automatically respond to window resizes, adjusting the size of all the widgets inside layouts. This way the applications looks good when the window is small and continues to look natural when maximised. The alternative would be to hardcode the window sizes, which is error-prone and takes a lot of time.



  • Hi sierdzio - perfect hints for cute start :)



  • You could instead use a QGraphicsView for the board and QGraphicsPixmapItems for the 'tokens'.

    It might take longer to implement though, depending on your learning curve.


Log in to reply