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. Transparency in Table/Tree View/WIdget with setAlternatingRowColors and Delegate
Forum Updated to NodeBB v4.3 + New Features

Transparency in Table/Tree View/WIdget with setAlternatingRowColors and Delegate

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 2 Posters 3.6k 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.
  • gde23G Offline
    gde23G Offline
    gde23
    wrote on last edited by
    #11

    Thanks for the further hint. I've tried that, the grey header is smaller now, but it still may overlap.
    What I've also noticed is, that the Text seems to be renderd twice with a small ofset somehow when it is overlapping.
    overlap2.png

    Also with the text when i do not clip to rect the overlap is gone.

    mrjjM 1 Reply Last reply
    0
    • gde23G gde23

      Thanks for the further hint. I've tried that, the grey header is smaller now, but it still may overlap.
      What I've also noticed is, that the Text seems to be renderd twice with a small ofset somehow when it is overlapping.
      overlap2.png

      Also with the text when i do not clip to rect the overlap is gone.

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

      @gde23
      oK so it really just is the "editor" you new to render with.
      That explains why it can be over scrollbar :)

      gde23G 1 Reply Last reply
      1
      • mrjjM mrjj

        @gde23
        oK so it really just is the "editor" you new to render with.
        That explains why it can be over scrollbar :)

        gde23G Offline
        gde23G Offline
        gde23
        wrote on last edited by gde23
        #13

        @mrjj
        Ok :) so but what could be the reason? Or do you have any ideas for fixing it?

        EDIT: I've also tested some "compact mode" where i can remove the header from the cells, and the view will be shown without the cell headers.

        When I switch to compact mode the artefacts stay there for a while and only dissapear after a few clicks or something.
        So at that moment the editors arent even there any more. Could this be a timing problem maybe?

        mrjjM 1 Reply Last reply
        0
        • gde23G gde23

          @mrjj
          Ok :) so but what could be the reason? Or do you have any ideas for fixing it?

          EDIT: I've also tested some "compact mode" where i can remove the header from the cells, and the view will be shown without the cell headers.

          When I switch to compact mode the artefacts stay there for a while and only dissapear after a few clicks or something.
          So at that moment the editors arent even there any more. Could this be a timing problem maybe?

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

          @gde23
          Can you show how DummyDelegate is defined?

          Is it a widget ?

          You could try to just hide it as it will render anyway
          editor = new DummyDelegate();
          editor ->hide()

          1 Reply Last reply
          1
          • gde23G Offline
            gde23G Offline
            gde23
            wrote on last edited by
            #15

            Dummy Delegate is just a normal widget with layouts on it that hold other widgets

            DummyDelegat::DummyDelegat(QWidget *parent):
                QWidget(parent),
                m_compact_mode(false)
            {
                m_main_layout = new QVBoxLayout();
                m_main_layout->setSpacing(2);
                m_main_layout->setContentsMargins(0, 0, 0, 0);
            
                m_main_layout->setAlignment(Qt::AlignTop);
                this->setLayout(m_main_layout);
            
                m_header = new QWidget(this);
                m_header->setFixedHeight(12);
            
                m_main_layout->addWidget(m_header);
            
                m_header_layout = new QHBoxLayout();
                m_header_layout->setContentsMargins(5, 0, 0, 0);
                m_header_layout->setSpacing(2);
                m_header->setLayout(m_header_layout);
            
                m_header_icon_label = new QLabel(this);
                m_header_icon_label->setFixedHeight(12);
                m_header_icon_label->setFixedWidth(12);
            
                m_header_layout->addWidget(m_header_icon_label);
            
                m_header_label = new QLabel(this);
                m_header_layout->addWidget(m_header_label);
            }
            
            mrjjM 1 Reply Last reply
            0
            • gde23G gde23

              Dummy Delegate is just a normal widget with layouts on it that hold other widgets

              DummyDelegat::DummyDelegat(QWidget *parent):
                  QWidget(parent),
                  m_compact_mode(false)
              {
                  m_main_layout = new QVBoxLayout();
                  m_main_layout->setSpacing(2);
                  m_main_layout->setContentsMargins(0, 0, 0, 0);
              
                  m_main_layout->setAlignment(Qt::AlignTop);
                  this->setLayout(m_main_layout);
              
                  m_header = new QWidget(this);
                  m_header->setFixedHeight(12);
              
                  m_main_layout->addWidget(m_header);
              
                  m_header_layout = new QHBoxLayout();
                  m_header_layout->setContentsMargins(5, 0, 0, 0);
                  m_header_layout->setSpacing(2);
                  m_header->setLayout(m_header_layout);
              
                  m_header_icon_label = new QLabel(this);
                  m_header_icon_label->setFixedHeight(12);
                  m_header_icon_label->setFixedWidth(12);
              
                  m_header_layout->addWidget(m_header_icon_label);
              
                  m_header_label = new QLabel(this);
                  m_header_layout->addWidget(m_header_label);
              }
              
              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #16

              @gde23

              Ok so it really is just a floating Widget.

              Did you try to hide it ?

              gde23G 1 Reply Last reply
              1
              • mrjjM mrjj

                @gde23

                Ok so it really is just a floating Widget.

                Did you try to hide it ?

                gde23G Offline
                gde23G Offline
                gde23
                wrote on last edited by
                #17

                @mrjj Hiding the editor in the paint() method after creation does not make any difference

                mrjjM 1 Reply Last reply
                0
                • gde23G gde23

                  @mrjj Hiding the editor in the paint() method after creation does not make any difference

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

                  @gde23
                  Ok. I have no idea then
                  as its clearly the grey we see.

                  I wonder one thing
                  You don't give it a parent when you new it -
                  so how do you avoid it having borders etc like a Window normally have?

                  editor = new DummyDelegate( NO PARENT );

                  Also you could try to give it a parent to see if that keeps it inside

                  gde23G 1 Reply Last reply
                  1
                  • mrjjM mrjj

                    @gde23
                    Ok. I have no idea then
                    as its clearly the grey we see.

                    I wonder one thing
                    You don't give it a parent when you new it -
                    so how do you avoid it having borders etc like a Window normally have?

                    editor = new DummyDelegate( NO PARENT );

                    Also you could try to give it a parent to see if that keeps it inside

                    gde23G Offline
                    gde23G Offline
                    gde23
                    wrote on last edited by
                    #19

                    @mrjj I've tried setting the treeview as parent when creating the editor: No change :(

                    Anyway, thanks a lot for all the hints you gave. I'll really try to set up a minimal example now as soon as i find some time.

                    mrjjM 1 Reply Last reply
                    0
                    • gde23G gde23

                      @mrjj I've tried setting the treeview as parent when creating the editor: No change :(

                      Anyway, thanks a lot for all the hints you gave. I'll really try to set up a minimal example now as soon as i find some time.

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

                      @gde23
                      Hi
                      Ok that is very , very odd then.
                      You're welcome.
                      Im sure it has a rational explanation.
                      A minimal example would be good.! :)

                      gde23G 1 Reply Last reply
                      1
                      • mrjjM mrjj

                        @gde23
                        Hi
                        Ok that is very , very odd then.
                        You're welcome.
                        Im sure it has a rational explanation.
                        A minimal example would be good.! :)

                        gde23G Offline
                        gde23G Offline
                        gde23
                        wrote on last edited by
                        #21

                        @mrjj Yeah :) I finally got it working with your help.

                        The trick is to first add the View as a parent for the DelgateEditor.
                        Now we still get the overlap. However now when you remove painter->setClipRect(option.rect); from paint() is does not paint into neighboring cells any more, so you do not need that line of code anymore and without that line of code the problem is gone :)

                        Thanks again for all the help, I never would have come up with that idea. (And I still don't get why it did not work in the first place)

                        mrjjM 1 Reply Last reply
                        2
                        • gde23G gde23

                          @mrjj Yeah :) I finally got it working with your help.

                          The trick is to first add the View as a parent for the DelgateEditor.
                          Now we still get the overlap. However now when you remove painter->setClipRect(option.rect); from paint() is does not paint into neighboring cells any more, so you do not need that line of code anymore and without that line of code the problem is gone :)

                          Thanks again for all the help, I never would have come up with that idea. (And I still don't get why it did not work in the first place)

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

                          @gde23
                          Good to hear :)
                          Also, I not sure what really happened but i suspect render() and setClipRect had
                          some synergies im not aware of :)

                          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