Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Could the qtablewidgetitem set the stylesheet?
Qt 6.11 is out! See what's new in the release blog

Could the qtablewidgetitem set the stylesheet?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 519 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    I found that the item object is not inherited from the qobject .I just want to use the stylesheet on the qtablewidgetitem.
    Or is there a simple way to modify the style of the items?not the whole style ,may be many colors or and so on.

    JonBJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      I found that the item object is not inherited from the qobject .I just want to use the stylesheet on the qtablewidgetitem.
      Or is there a simple way to modify the style of the items?not the whole style ,may be many colors or and so on.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @nicker-player
      As you have discovered QTableWidgetItems are not QWidgets and hence cannot have stylesheets applied to them. You can style QTableWidget/QTableView and their items (e.g. QTableView::item) as a whole, but not individual items if that is what you want.

      If you want to access individual items you would need to do that in code by overriding QTableWidget::data() or calling QTableWidget::setData() with one of the roles it offers, or there are a few specific methods to do this, e.g. QTableWidgetItem::setForeground().

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tink
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • jeremy_kJ Offline
          jeremy_kJ Offline
          jeremy_k
          wrote on last edited by
          #4

          A custom item delegate might be required.

          Asking a question about code? http://eel.is/iso-c++/testcase/

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved