PDA

View Full Version : model view pixmap table help



Bennieboj
11th November 2011, 14:45
Hi everyone,

First of all, I didn't know where to put this. I was stuck inbetween newbie forum and the normal qt programming forum. So if needed, feel free to move this topic.

The situation: I have made a chess program (coded in c++, made in MSVS2010) user input is handled by a simple commandline interface.
Now I wanted to port this to Qt, using the model/view paradigm.
I already studied the model/view paradigm with the normal model classes (like QAbstractTableModel etc, and classes inhereted from that one), which works fine.

The problem: I can't get this to work on my own code... I have an array of pointers to my chess pieces (I currently only use pawns) in my gameboard class. I don't get how to make my model and view not get it to work with my previous c++ code.

Can someone help me with this please?

Bennieboj
12th November 2011, 09:18
one heads up, we normally have to use QGraphicsView to show the chessboard, but since I can't get it to work now, I'll certainly can't get it to work with QGraphicsView

Can someone give me an example please?

sorry for the doubleposting, but I couldn't find the edit-button

grin
12th November 2011, 09:55
Hi, you can use QStandartItemModel as model (set pixmap throuth setData(Qt::DecorationRole) for item) and (IMHO) you have to create subclass of QTableView for manipulate with user's input. I think it's all, that you need. =)

Lykurg
12th November 2011, 10:03
Well, QTableView is hardly the best way to make a gui for a chess game. I'd go for a QGraphicsView. There you can allow the user to move the figures by mouse and so on, and make some nice effects. Depending on what your interaction the the chess program is, use signal and slots to update the view and vice versa.

Bennieboj
12th November 2011, 13:38
Thanks for the replies, I'll try what you guys said.
If I still don't get it to work, I'll ask here :)