Results 1 to 4 of 4

Thread: Icon, in front of QTableWidget row

  1. #1
    Join Date
    Mar 2011
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Icon, in front of QTableWidget row

    Hello,

    What I'm trying to do is having a small icon in front of a row in a QTableWidget. This is the code I've so far:

    Qt Code:
    1. QTableWidgetItem * test = new QTableWidgetItem("00400000");
    2. test->setBackground(QBrush(Qt::green));
    3. QIcon qilel(":/Resources/red_arrow.png");
    4. test->setIcon(qilel);
    5. ui.SendList->setItem(0,1,test);
    To copy to clipboard, switch view to plain text mode 

    the qilel value of QIcon, is my code + resource map and then the red_arrow is the png I would like to add. The prolbme is that I don't see any Icon

    Further when I use verticalHeader()->hide(); for the table will this still work, if I get this to work anyways.

    Thanks,

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 334 Times in 317 Posts

    Default Re: Icon, in front of QTableWidget row

    is the image file present in given location ??

  3. #3
    Join Date
    Mar 2011
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Icon, in front of QTableWidget row

    euhm, yes its in the resource map.

  4. #4
    Join Date
    Mar 2011
    Posts
    33
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Icon, in front of QTableWidget row

    Bumb with info

    I found out that I can get it to work with the Qt Designer.

    Normally the vertical header has 1,2,3,4,5,6, etc for the row. I want to change the number sometimes for a icon and sometimes hide it.

    What I tried

    i.SendList->verticalHeaderItem(5)->setIcon(qilel);

    This does not work, but it crashes with: "unhandled expcetion at ..... Acces violation reading location ...."


    Also,

    ui.ButIgnore->setIcon(qilel);
    ui.ButIgnore->setIconSize(QSize(5,5));

    this si to test if the gilel has a picture inside it, the button stays white, ideas?

    Grz

Similar Threads

  1. Using pthreads for a front end
    By kachofool in forum Newbie
    Replies: 1
    Last Post: 5th October 2009, 23:13
  2. QTableWidget + Icon
    By NoRulez in forum Qt Programming
    Replies: 3
    Last Post: 23rd July 2008, 19:29
  3. Bring QDialog to front
    By mitro in forum Newbie
    Replies: 3
    Last Post: 21st April 2008, 21:32
  4. Qt3 Bring to front application
    By nleverin in forum Qt Programming
    Replies: 1
    Last Post: 7th February 2008, 12:27
  5. How to bring a dialogbox to the front?
    By bood in forum Qt Programming
    Replies: 2
    Last Post: 2nd August 2006, 16:04

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.