Results 1 to 3 of 3

Thread: qtableview and images in the cell

  1. #1
    Join Date
    Apr 2006
    Posts
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default qtableview and images in the cell

    Hi all,

    writing an Bulls and Cows game, a Mastermind like game
    http://qt-apps.org/content/show.php/...content=169027

    I have tableview/model and i have lineEdit where you enter data; application checks the data and calculates score(bulls,cows)
    bull = you have guessed the number and its in the right position
    cow = you have guessed the number but not in good position

    in 1 cell you have your guess and then currently i have cell bullz and cell cows
    i'd like to replace this with following
    in 1st cell your guess and in second cell images of bulls and cows;
    But i don't know how to put in cell multiple and different images;
    for example if you have 1 bull and 2 cows score how do i put that in the cell

    I can put only one image

    QStandardItem *itemScore = new QStandardItem();
    for (int i=0; i<bulls;i++) {
    itemScore->setData(QPixmap("Red-bull.png").scaledToHeight(35),Qt:ecorationRole);
    }
    for (int i=0; i<cows;i++) {
    itemScore->setData(QPixmap("Yellow-cow.png").scaledToHeight(35),Qt:ecorationRole);
    }
    tmodel->setItem(row,3,itemScore);


    thanks for helping

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qtableview and images in the cell

    Just generate an image, i.e. drawing into a QPixmap or QImage using QPainter.

    Cheers,
    _

  3. #3
    Join Date
    Apr 2006
    Posts
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtableview and images in the cell

    thanks for the replay

    i'll try to implement qpainter.drawImage

Similar Threads

  1. how to color a cell in a QTableView
    By JeanC in forum Qt Programming
    Replies: 13
    Last Post: 9th September 2015, 10:08
  2. Jump to a cell in QTableView
    By toodles in forum Qt Programming
    Replies: 1
    Last Post: 30th June 2012, 06:07
  3. Add QPushButton to cell in QTableView?
    By nikhil in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2010, 09:01
  4. How to tell if QTableView cell is visible ?
    By steviekm3 in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2009, 10:04
  5. How to tell if cell in QTableView is visible ??
    By steviekm3 in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2009, 17:57

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
  •  
Qt is a trademark of The Qt Company.