QTableWidget vs QTableView for game boards? Or something else?

  • I'm making a series of game boards for solvers. Think checkers, sudoku, othello, go, chess. These sorts of things aren't really the same as spreadsheets. The backing data, the models or items, are series of gameboards all at different positions, one move ahead, two moves ahead, and so on. There could be hundreds and hundreds of boards in memory to evaluate different game moves. Backtracking and so on.

    But only one screen in front of the user.

    So for compactness and flexibility, which underlying model/view/item classes make sense for game boards?

    Each square on the board has just a few bits of information, but becomes a displayed cell on the screen, at some point. So speed and compactness are of greatest importance.

  • "QTableWidget":http://doc.qt.nokia.com/latest/qtablewidget.html an item-based table view with a default model. The items in a QTableWidget are "QTableWidgetItem":http://doc.qt.nokia.com/latest/qtablewidgetitem.html

    And if you want a table that uses your own data model you should use "QTableView":http://doc.qt.nokia.com/latest/qtableview.html rather than QTableWidget.

  • I think, for a game board, you need a special widget. YOu have fix cell properties (height, size, ...) perhaps you need not squares but triangles etc...

  • I think you'll have to come up with your own models for this. The default item models that come with Qt are simply not suitable for such an application. Also, I think that for visualization you probably need something else than a QTableView (or -Widget, for that matter). A game board is not a table.

    For visualization, you might look into QML.

  • you could try using labels (With icons) and a Grid layout, maybe an array of labels that represents each square and another array with icons that represent the player, you cant try that way..

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.