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. Widget overlapping other widget in QGridLayout is visible, but unresponsive
Forum Updated to NodeBB v4.3 + New Features

Widget overlapping other widget in QGridLayout is visible, but unresponsive

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 847 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.
  • qwasder85Q Offline
    qwasder85Q Offline
    qwasder85
    wrote on last edited by qwasder85
    #1

    I have a somewhat special setup that (mis-)uses a QGridLayout to stack one widget over another. Something like this:

    QWidget *p_sidebar = new QWidget; // Orange widget
    p_sidebar->setFixedWidth(50);
    
    QWidget *p_work_area = new QWidget; // Blue widget
    
    QGridLayout *p_layout = new QGridLayout;
    p_layout ->addWidget(p_work_area, 0, 0);
    p_layout ->addWidget(p_sidebar, 0, 0);
    

    alt text
    The idea is to have p_work_area span across the window and p_sidebar sitting above it on the left side. Then I can expand p_sidebar's width to show some settings on it while it overlaps p_work_area instead of pushing it to the side.

    The odd thing is that this works visually with p_sidebar correctly sitting on top, but it remains unresponsive to clicks. instead they are registered on p_work_area underneath.
    I know that I'm abusing the grid layout with this, but it would've been a pretty neat solution to this UI requirement.

    Can someone explain to me why the widget (that apparently sits on top) does not receive the mouse input in this configuration?

    Thanks!

    J.HilkJ 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can not have two widgets at the same grid layout possition

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      J.HilkJ 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        You can not have two widgets at the same grid layout possition

        J.HilkJ Online
        J.HilkJ Online
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @Christian-Ehrlicher thats not true, you actually can.

        Its not possible from the designer, yes, but you can, like the OP did set multiple QWidgets in one grid layout position.

        Or it used to work in Qt5 at least, haven't done/tried it in Qt6


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        Christian EhrlicherC 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @Christian-Ehrlicher thats not true, you actually can.

          Its not possible from the designer, yes, but you can, like the OP did set multiple QWidgets in one grid layout position.

          Or it used to work in Qt5 at least, haven't done/tried it in Qt6

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @J-Hilk said in Widget overlapping other widget in QGridLayout is visible, but unresponsive:

          Or it used to work in Qt5 at least, haven't done/tried it in Qt6

          You will not get an error message but it will also not work as expected - e.g. only the size hint of the second will be taken into account and others as you can see in the problem description from the OP

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          qwasder85Q 1 Reply Last reply
          2
          • qwasder85Q qwasder85

            I have a somewhat special setup that (mis-)uses a QGridLayout to stack one widget over another. Something like this:

            QWidget *p_sidebar = new QWidget; // Orange widget
            p_sidebar->setFixedWidth(50);
            
            QWidget *p_work_area = new QWidget; // Blue widget
            
            QGridLayout *p_layout = new QGridLayout;
            p_layout ->addWidget(p_work_area, 0, 0);
            p_layout ->addWidget(p_sidebar, 0, 0);
            

            alt text
            The idea is to have p_work_area span across the window and p_sidebar sitting above it on the left side. Then I can expand p_sidebar's width to show some settings on it while it overlaps p_work_area instead of pushing it to the side.

            The odd thing is that this works visually with p_sidebar correctly sitting on top, but it remains unresponsive to clicks. instead they are registered on p_work_area underneath.
            I know that I'm abusing the grid layout with this, but it would've been a pretty neat solution to this UI requirement.

            Can someone explain to me why the widget (that apparently sits on top) does not receive the mouse input in this configuration?

            Thanks!

            J.HilkJ Online
            J.HilkJ Online
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @Christian-Ehrlicher interesting, never dove to deep into the situation. The size hint was always all I needed from this hack :D

            @qwasder85 have you considered fusing p_work_area and p_sidebar into one custom QWidget ? should solve your issues


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @J-Hilk said in Widget overlapping other widget in QGridLayout is visible, but unresponsive:

              Or it used to work in Qt5 at least, haven't done/tried it in Qt6

              You will not get an error message but it will also not work as expected - e.g. only the size hint of the second will be taken into account and others as you can see in the problem description from the OP

              qwasder85Q Offline
              qwasder85Q Offline
              qwasder85
              wrote on last edited by
              #6

              @Christian-Ehrlicher The result is a mixed situation. The widgets are resizing/moving correctly within the layout. But as I mentioned, they appear to not work correctly otherwise.

              @J-Hilk I certainly can create a completely custom widget for this case. But it would be too much effort for me right now. If this worked the way I tried, it would have solved my issues really elegantly.

              Thank you, guys.

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @qwasder85 I don't know Qt's event forwarding code by heart, but my guess is that it uses layout as a shortcut to find the right widget and it gets confused by this.

                Honestly, unless it's documented somewhere, this looks more like a bug than a feature. I wouldn't rely on it even if it worked.

                Can't you just make p_sidebar a child of p_work_area if you want to cover it? Sounds like a more sensible approach structure wise.

                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