Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QTableWidget vs QTableView for game boards? Or something else?
Reliance last edited by
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.
Zlatomir last edited by
"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.
giesbert last edited by
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...
andre last edited by
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.
Iktwo last edited by
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..