Results 1 to 2 of 2

Thread: Gameboard representation in QT

  1. #1
    Join Date
    Nov 2013
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    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 http://stackoverflow.com/questions/1...g-and-dropping 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
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    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.

    Cheers,
    _

Similar Threads

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

Tags for this Thread

Bookmarks

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.