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. itemdelegate ignores stylesheet
Forum Updated to NodeBB v4.3 + New Features

itemdelegate ignores stylesheet

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 2 Posters 1.5k 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.
  • M Offline
    M Offline
    Megamouse
    wrote on 25 Jun 2018, 01:55 last edited by
    #1

    Hi,

    I want to give the tablewidget items a nice padding.
    But as soon as i use QTableWidget::setItemDelegate the following stylesheet won't apply anymore:

    QTableView::item {
        border-left: 4px solid white;
        border-right: 4px solid white;
    }
    

    Why could this be happening?

    R 1 Reply Last reply 25 Jun 2018, 06:55
    0
    • M Megamouse
      25 Jun 2018, 01:55

      Hi,

      I want to give the tablewidget items a nice padding.
      But as soon as i use QTableWidget::setItemDelegate the following stylesheet won't apply anymore:

      QTableView::item {
          border-left: 4px solid white;
          border-right: 4px solid white;
      }
      

      Why could this be happening?

      R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 25 Jun 2018, 06:55 last edited by
      #2

      @Megamouse said in itemdelegate ignores stylesheet:

      But as soon as i use QTableWidget::setItemDelegate

      what type of item delegate?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Megamouse
        wrote on 25 Jun 2018, 15:31 last edited by
        #3

        I use a subclass of QItemDelegate with a drawFocus override that I use to prevent the ugly dotted selection rectangles around the items.
        But even if I simply use a default QItemDelegate it won't apply the style.

        So I'm looking for either a way to apply those styles to the items WITH the delegate applied,
        or
        for a way to remove the selection rectangles without using a delegate.

        R 1 Reply Last reply 25 Jun 2018, 17:13
        0
        • M Megamouse
          25 Jun 2018, 15:31

          I use a subclass of QItemDelegate with a drawFocus override that I use to prevent the ugly dotted selection rectangles around the items.
          But even if I simply use a default QItemDelegate it won't apply the style.

          So I'm looking for either a way to apply those styles to the items WITH the delegate applied,
          or
          for a way to remove the selection rectangles without using a delegate.

          R Offline
          R Offline
          raven-worx
          Moderators
          wrote on 25 Jun 2018, 17:13 last edited by raven-worx
          #4

          @Megamouse said in itemdelegate ignores stylesheet:

          I use a subclass of QItemDelegate

          k, then you need to subclass QStyledItemDelegate instead.
          For obvious reasons ;)

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2
          • M Offline
            M Offline
            Megamouse
            wrote on 25 Jun 2018, 18:20 last edited by
            #5

            That works for the stylesheet :) , but now I can't override drawFocus anymore to remove the selection rectangles :(

            R 1 Reply Last reply 26 Jun 2018, 06:36
            0
            • M Megamouse
              25 Jun 2018, 18:20

              That works for the stylesheet :) , but now I can't override drawFocus anymore to remove the selection rectangles :(

              R Offline
              R Offline
              raven-worx
              Moderators
              wrote on 26 Jun 2018, 06:36 last edited by
              #6

              @Megamouse
              either in the initStyleOption() or in the paint() method do:

              option->state &= ~QStyle::State_HasFocus
              

              and draw the desired focus rect yourself

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              3
              • M Offline
                M Offline
                Megamouse
                wrote on 28 Jun 2018, 21:29 last edited by
                #7

                @raven-worx worked like a charm. Thank you.

                Only the selection-background-color seems to be useless in the TableWidget stylesheet, so I simply styled QTableView::item:selected instead.

                The selection-color works though

                1 Reply Last reply
                0

                5/7

                25 Jun 2018, 18:20

                • Login

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