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 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.

    mrjjM 1 Reply Last reply
    0
    • L Lobstw

      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.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on 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
      1
      • mrjjM mrjj

        @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 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

        mrjjM 1 Reply Last reply
        0
        • L Lobstw

          @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

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          L 1 Reply Last reply
          1
          • mrjjM mrjj

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

            L Offline
            L Offline
            Lobstw
            wrote on 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.

            mrjjM 1 Reply Last reply
            0
            • L Lobstw

              @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.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on 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
              1
              • mrjjM mrjj

                @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 last edited by
                #7

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

                mrjjM 1 Reply Last reply
                0
                • L Lobstw

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

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 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

                  • Login

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