Results 1 to 3 of 3

Thread: how to make icon sell unhighlightable in tableWidget?

  1. #1
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    1

    Default how to make icon sell unhighlightable in tableWidget?

    Hello

    I added a tableWidget, and want to have 1st column with name and 2nd column with status icon.
    But I don't want the user to highlight the cell. (no interaction at all.)
    I tried to use Qt::ItemIsEnabled, but it made my icon gray.
    Is there any better approach I can try?
    Thanks a lot.


    Qt Code:
    1. int rowCount = ui->tableWidget->rowCount();
    2. ui->tableWidget->insertRow(rowCount);
    3.  
    4. QTableWidgetItem* item = new QTableWidgetItem(user_name);
    5. ui->tableWidget->setItem(rowCount, 0, item);
    6.  
    7. // Connection status.
    8. item = new QTableWidgetItem;
    9. QIcon icon_connection(":/images/connected.png");
    10. item->setIcon(icon_connection);
    11. item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
    12. ui->tableWidget->setItem(rowCount, 1, item);
    13. item->setToolTip(CONNECTION_STATUS);
    To copy to clipboard, switch view to plain text mode 

  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: how to make icon sell unhighlightable in tableWidget?

    Qt::ItemIsSelectable?

    Cheers,
    _

  3. #3
    Join Date
    Apr 2016
    Posts
    5
    Thanks
    1

    Default Re: how to make icon sell unhighlightable in tableWidget?

    Thanks a lot, but actually I've tried with that.
    For some reason, I've got a dotted line around the cell I selected.
    Do you know how I can remove the line?
    Untitled.png

Similar Threads

  1. Is it possible to sell software developed under LGPL Qt?
    By Awareness in forum General Discussion
    Replies: 5
    Last Post: 4th July 2011, 18:52
  2. Replies: 1
    Last Post: 15th December 2010, 13:20
  3. How to make an icon widget draggable
    By curiouswalker in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2010, 01:23
  4. how can I make the Icon larger
    By duduqq in forum Qt Programming
    Replies: 1
    Last Post: 8th July 2008, 02:28

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.