Results 1 to 5 of 5

Thread: model view pixmap table help

  1. #1
    Join Date
    Nov 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default model view pixmap table help

    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?

  2. #2
    Join Date
    Nov 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: model view pixmap table help

    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

  3. #3
    Join Date
    Apr 2010
    Location
    Russian Federation, Kaluga
    Posts
    20
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: model view pixmap table help

    Hi, you can use QStandartItemModel as model (set pixmap throuth setData(Qt:ecorationRole) 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. =)

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: model view pixmap table help

    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.

  5. #5
    Join Date
    Nov 2011
    Posts
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: model view pixmap table help

    Thanks for the replies, I'll try what you guys said.
    If I still don't get it to work, I'll ask here

Similar Threads

  1. Q Table View + Relational Model VERY SLOW
    By arimaniac in forum Qt Programming
    Replies: 0
    Last Post: 8th December 2010, 16:43
  2. Replies: 33
    Last Post: 7th December 2009, 10:11
  3. Table view->model->set data
    By tulsi in forum Qt Programming
    Replies: 3
    Last Post: 21st April 2009, 08:36
  4. [model/view] slow refresh on big table
    By lauranger in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2008, 21:40
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

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.