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. setPalette for QTableWidgetItem in Qt5

setPalette for QTableWidgetItem in Qt5

Scheduled Pinned Locked Moved Solved General and Desktop
qt5.5qtablewidgetpython
8 Posts 2 Posters 3.2k Views
  • 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.
  • L Offline
    L Offline
    Lobstw
    wrote on 24 Nov 2015, 12:17 last edited by
    #1

    Is the setPalette option still available for table cells in Qt5?

    I am trying to partially fill the background of a table cell. So if cell value is 50 then make cell background half filled with yellow.

    M 1 Reply Last reply 24 Nov 2015, 18:52
    0
    • L Lobstw
      24 Nov 2015, 12:17

      Is the setPalette option still available for table cells in Qt5?

      I am trying to partially fill the background of a table cell. So if cell value is 50 then make cell background half filled with yellow.

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 24 Nov 2015, 18:52 last edited by
      #2

      @Lobstw
      I think not but it has setbrush and it can make gradiants
      QRadialGradient gradient(50, 50, 50, 50, 50);
      gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
      gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
      QBrush brush(gradient);

      L 1 Reply Last reply 24 Nov 2015, 19:37
      1
      • M mrjj
        24 Nov 2015, 18:52

        @Lobstw
        I think not but it has setbrush and it can make gradiants
        QRadialGradient gradient(50, 50, 50, 50, 50);
        gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
        gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
        QBrush brush(gradient);

        L Offline
        L Offline
        Lobstw
        wrote on 24 Nov 2015, 19:37 last edited by Lobstw
        #3

        @mrjj I don't think table items have a setbrush. The only set options that I can see are available are: (Background, Checkstate, Data, Flags, Font, Foreground, Icon, Selected, SizeHint, StatusTip, Text, Text Alignment, Tooltip, WhatsThis)

        edit: setBackground and setForeground come from QBrush though

        M 1 Reply Last reply 24 Nov 2015, 19:45
        0
        • L Lobstw
          24 Nov 2015, 19:37

          @mrjj I don't think table items have a setbrush. The only set options that I can see are available are: (Background, Checkstate, Data, Flags, Font, Foreground, Icon, Selected, SizeHint, StatusTip, Text, Text Alignment, Tooltip, WhatsThis)

          edit: setBackground and setForeground come from QBrush though

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 24 Nov 2015, 19:45 last edited by
          #4

          @Lobstw
          Hi yes it was
          setBackground(const QBrush & brush) i was thinking of.

          L 1 Reply Last reply 24 Nov 2015, 20:45
          1
          • M mrjj
            24 Nov 2015, 19:45

            @Lobstw
            Hi yes it was
            setBackground(const QBrush & brush) i was thinking of.

            L Offline
            L Offline
            Lobstw
            wrote on 24 Nov 2015, 20:45 last edited by
            #5

            @mrjj Hello, setBackground seems to have done the trick, how may I apply it to only a part of the cell instead of the whole thing? Thank you.

            M 1 Reply Last reply 24 Nov 2015, 20:55
            0
            • L Lobstw
              24 Nov 2015, 20:45

              @mrjj Hello, setBackground seems to have done the trick, how may I apply it to only a part of the cell instead of the whole thing? Thank you.

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 24 Nov 2015, 20:55 last edited by
              #6

              @Lobstw
              Hi
              brush is for whole cell, so you have to fake it and make gradiant be normal color in the end
              you want to look normal.

              L 1 Reply Last reply 24 Nov 2015, 21:58
              1
              • M mrjj
                24 Nov 2015, 20:55

                @Lobstw
                Hi
                brush is for whole cell, so you have to fake it and make gradiant be normal color in the end
                you want to look normal.

                L Offline
                L Offline
                Lobstw
                wrote on 24 Nov 2015, 21:58 last edited by
                #7

                @mrjj I used three setcolorat options and it works well! Great stuff

                M 1 Reply Last reply 24 Nov 2015, 21:59
                0
                • L Lobstw
                  24 Nov 2015, 21:58

                  @mrjj I used three setcolorat options and it works well! Great stuff

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 24 Nov 2015, 21:59 last edited by mrjj
                  #8

                  @Lobstw
                  Yes QRadialGradient is pretty awesome. :)
                  btw there is also QLinearGradient
                  http://doc.qt.io/qt-5.5/qgradient.html

                  just in case u didnt see them

                  1 Reply Last reply
                  1

                  1/8

                  24 Nov 2015, 12:17

                  • Login

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