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. [solved] QTableWidgetItem set StyleSheet
Forum Updated to NodeBB v4.3 + New Features

[solved] QTableWidgetItem set StyleSheet

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 23.1k Views 1 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.
  • B Offline
    B Offline
    BlackJack
    wrote on 15 Jan 2012, 13:14 last edited by
    #1

    Good day

    I have a QTableWidget, if there is some opportunity to set the StyleSheet for a specific item in the table, for example, item(3,2) ???

    In advance I thank

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on 15 Jan 2012, 21:07 last edited by
      #2

      You can customize the style of single cell using method "setData":http://developer.qt.nokia.com/doc/qt-4.8/qtablewidgetitem.html#setData. Try with something like:
      @
      table.item(3, 2).setData(Qt.BackgroundRole, QVariant(QColor(Qt::yellow)) );
      @

      http://anavi.org/

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BlackJack
        wrote on 16 Jan 2012, 09:04 last edited by
        #3

        thanks, but this unit only color, and how to impose a completely separate style to a cell ...

        something like
        @item(3,2).setStyleSheet("border:1px solid grey; border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;")@

        need to do a completely different style from the cell ...

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on 16 Jan 2012, 09:07 last edited by
          #4

          Stylesheets always work on widgets.

          Inside views, it is not possible to address single items with a style sheet or set a style sheet on them.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on 16 Jan 2012, 09:09 last edited by
            #5

            [quote author="BlackJack" date="1326704668"]thanks, but this unit only color, and how to impose a completely separate style to a cell ...

            something like
            @item(3,2).setStyleSheet("border:1px solid grey; border-bottom-left-radius: 5px;border-bottom-right-radius: 5px;")@

            need to do a completely different style from the cell ...[/quote]

            This is not possible by styling.
            It can only be achieved by creating a delegate which does customized painting. But take care, if you change borders and margins, the size of the cell might change so you have to adopt the rest of the row / rolumn.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

            1 Reply Last reply
            0
            • B Offline
              B Offline
              BlackJack
              wrote on 16 Jan 2012, 13:03 last edited by
              #6

              thanks, that pushed in the right side. topic is closed

              1 Reply Last reply
              0

              1/6

              15 Jan 2012, 13:14

              • Login

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