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. hovering over child widgets, Qt::WA_NoMousePropagation not working
Forum Updated to NodeBB v4.3 + New Features

hovering over child widgets, Qt::WA_NoMousePropagation not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
21 Posts 3 Posters 7.4k Views 2 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to the forums.
    I will try in a moment, but since you already have a subclass, did you also try
    overriding void QWidget::enterEvent(QEvent * event)
    and set event as handled ?

    1 Reply Last reply
    1
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Wait a minute
      class Label : public QLabel is parent
      childLabel(new QLabel("child")) is the QLabel you want to hover ?

      But you set the stylesheet to the parent (and it affects the QLabel child too)
      setStyleSheet(R"(
      QLabel:hover{background-color: blue;}
      #childLabel:hover{ background-color: yellow;}
      )");

      dont you mean

      childLabel->setStyleSheet(R"(
      QLabel:hover{background-color: blue;}
      #childLabel:hover{ background-color: yellow;}
      )");

      1 Reply Last reply
      0
      • O Offline
        O Offline
        OZaric
        wrote on last edited by OZaric
        #4

        Hi,
        Thank you for your fast reply !

        So what i want is to be able to hover both, but seperately, when mouse is over the child(childLabel) it should only! hover the child else it should hover the widget(the Label). (e.g. like in the doc but HoverMove should be like MouseMove)
        More or less i do not want the childLabel's HoverMove to be propagated to its parent

        I have considered reimplementing the enterEvent and somehow go on with comparing with HoverMove, but it is written in the doc that Qt::WA_NoMousePropagation attribute has to be set to get the desired effect. But I cant see any effect setting this attribute.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #5

          Hi
          Yes you are right. it should only hover one.
          Do you use class Label : public QLabel as the window ? ( and no mainwindow)
          (going to test it)

          1 Reply Last reply
          0
          • O Offline
            O Offline
            OZaric
            wrote on last edited by OZaric
            #6

            No, thats actually a bigger project, this was just a small illustrative example.
            I have ofc. a mainwindow and so on...
            I noticed this problem when i put a ComboBox(as selector) inside a StackedWidget. I am subclassing the widgets directly in order to inherit all the public members.
            I did something like this ...

            class StackedWidget : public QStackedWidget
            {
                StackedWidget(...) {analogous to above example}
                QComboBox pageComboBox;
            }
            
            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #7

              Hi
              I agree - its a bit odd.
              QLabel might have some special flag.
              Did you try with Qwidgets ?

              1 Reply Last reply
              0
              • O Offline
                O Offline
                OZaric
                wrote on last edited by
                #8

                I have tried it with QComboBox/QStackedWidget because thats actually where i need it.

                mrjjM 1 Reply Last reply
                0
                • O OZaric

                  I have tried it with QComboBox/QStackedWidget because thats actually where i need it.

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

                  @OZaric
                  Just tried with QWidgets and mainwindow and indeed the mouse
                  bleed through.

                  1 Reply Last reply
                  1
                  • O Offline
                    O Offline
                    OZaric
                    wrote on last edited by
                    #10

                    Anyway Thank You for your time !

                    mrjjM 1 Reply Last reply
                    0
                    • O OZaric

                      Anyway Thank You for your time !

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

                      @OZaric
                      It seems that Qt::WA_NoMousePropagation have no effect
                      Im using Qt 5.10
                      What version are you testing with ?

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        OZaric
                        wrote on last edited by OZaric
                        #12

                        I am working with Qt 5.9.3. I have here a few (including static builds), tested on all without success.

                        1 Reply Last reply
                        0
                        • mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by mrjj
                          #13

                          Hi
                          Seems parent widget always get a hover when you enter its area even if a child
                          is covering the entry area
                          alt text

                          Not sure its a bug or by design. Lets see what others say.

                          1 Reply Last reply
                          1
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by SGaist
                            #14

                            Hi,

                            Can you share your test sample ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • mrjjM Offline
                              mrjjM Offline
                              mrjj
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              Hi
                              https://www.dropbox.com/s/egw6zy7lodscqr5/hovertest.zip?dl=0

                              1 Reply Last reply
                              0
                              • O Offline
                                O Offline
                                OZaric
                                wrote on last edited by
                                #16

                                Samuel Gaist, the qt legend :D
                                I am reading you already for years in this forum!

                                Check it out, it seems like setting attr Qt::WA_NoMousePropagation has no effect at all.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  It is used in QComboBox.

                                  Did you already saw the QHoverEvent description especially the part about propagation ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0
                                  • O Offline
                                    O Offline
                                    OZaric
                                    wrote on last edited by OZaric
                                    #18

                                    It is used in QComboBox.

                                    Are you sure ? , because its not working for my QComboboxes neither!
                                    QComboBox Mouse is over the left history button in this picture.

                                    Did you already saw the QHoverEvent description especially the part about propagation ?

                                    I did. This link is actually also in my original question.

                                    1 Reply Last reply
                                    0
                                    • mrjjM Offline
                                      mrjjM Offline
                                      mrjj
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      Hi
                                      The sample sets Qt::WA_NoMousePropagation on "CHILD"
                                      in mainwindows ctor but it made no difference.

                                      The CHILD label seems to be aligned with Parents client rect and in theory
                                      cursor should be able to enter the CHILD directly but i suspect the truth is
                                      that entering a widget always enters the parent first regardless of the visual
                                      representation.

                                      alt text

                                      1 Reply Last reply
                                      0
                                      • SGaistS Offline
                                        SGaistS Offline
                                        SGaist
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #20

                                        Sorry, I misread the link you used.

                                        As for QComboBox, yes I am. See here.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0
                                        • O Offline
                                          O Offline
                                          OZaric
                                          wrote on last edited by
                                          #21

                                          Hmmm ok.

                                          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