Results 1 to 2 of 2

Thread: Gameboard representation in QT

  1. #1
    Join Date
    Nov 2013
    Qt products

    Default Gameboard representation in QT

    I am trying to represent a gameboard for a user to interact with. It needs to be a 9x9 Grid which they can move the two to three different player pieces around and send signals to the main game object with the new position after a move. The game object would give coordinates for where to draw pieces on the board. I was originally planning on using QGraphicsView to represent the board but it is beginning to look a lot more complicated then it needs to be for the board representation. I found a post here on how to represent a grid but it seems difficult to set a specific grid size, keep the grid in the users view, and add nice graphics to it. After looking online it seems alot of people who write similar programs are using QML and the GridView to represent their boards. What would be the most recommended route for constructing the game board, allowing users to manipulate pieces etc. Also if I do use QML is there an easy way to add it into my QMainWindow derived window or will I have to design the whole window and not just the board element in QML. This is my first QT project so I am sorry if I am asking an overly basic question here. Also would I be able to handle all the QML logic with C++ or would I have to incorporate JS as well?

  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Gameboard representation in QT

    Well, I would have also gone for QGraphicsView, but regarding your QtQuick questions:

    You can use QMainWindow easily with QtQuick1, since a QDeclarativeView is a QWidget and can therefore be used as the main window's central widget.

    If you want to go with QtQuick2, then you can still do that by using QWidget::createWindowContainer() to wrap the QQuickView in a widget.

    In either case you can, and in fact should, do all logic in C++. Either by exposing C++ API using the QML engine's root context (set objects as context properties) or my making a type of your own instantiable from QML.


Similar Threads

  1. representation of numbers in QTableView...
    By KillGabio in forum Newbie
    Replies: 4
    Last Post: 26th January 2012, 04:59
  2. true representation in binary or hex
    By Tadas in forum Newbie
    Replies: 12
    Last Post: 10th October 2010, 20:02
  3. Graphical representation of an array
    By ithinkso in forum Qt Programming
    Replies: 2
    Last Post: 6th March 2010, 00:30
  4. Tree related representation
    By aegis in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2007, 13:20
  5. Replies: 1
    Last Post: 2nd April 2007, 23:52

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.