'QScrollArea doesn't work when the mouse is at the edge of the window

Introduction: I am developing a Qt application in C++ in which I have a vertical menu implemented using QScrollArea on the right side of the window. The menu can contain an unlimited amount of objects, so I needed a vertical slider and an option for the user to scroll through the objects.

Design of the window

Problem: The scrollbar works just fine until my mouse is at the very edge (right) of the window. For example, when the window is maximized, I want to move my mouse to the right edge of the screen, press it and move the scrollbar vertically. However, the scrollbar doesn't work until I move my mouse to the left by 1px or more. (The window does not have to be maximized and there still is that 1px thick area between the scrollbar and the OS's window resizing feature)

Object hierarchy: My QMainWindow contains a QSplitter (window's central widget), which contains Environment on the left side and SequenceDiagramMenu on the right side. Finally, the SequenceDigramMenu contains the QScrollArea visible at the right edge of the window.

I've tried to search for margins in my .ui files, but didn't find any. Anyway, I tried to set margins of all mentioned components (window, splitter, menu, scroll area) to zeros, but that didn't help either. I've also tried making the SequenceDiagramMenu the central widget of the window, which didn't help either. What I didn't yet try is to make SequenceDiagramMenu inherit from QScrollArea, so the scroll area would not be IN the menu, but would BE the menu. I am trying to avoid this since I am using Qt forms and I doubt it would help anyways.

EDIT: I stretched the central widget all the way to the bottom and it seems that the horizontal scrollbar of the Environment (left side of the splitter) has the same problem.

This might seem like a minor bug but I'm confident it would annoy the user greatly after just several minutes of using the application.

Has anyone ever encountered this problem?

Thank you



Solution 1:[1]

Solution and a response to @mrg95

Initially, I have not applied any stylesheets to any of the components there.

However, I just tried to set the border of the QScrollArea to none and it worked! Although, as you predicted, the design is not suitable.

But! While looking at the .ui file of the menu, I had an idea and tried to set the QScrollArea's QFrame's frameShape to NoFrame and everything works perfectly now (it seems stupid I didn't try it sooner, but I did try to set the frame width to 0px, which did not help). The design is as it was and scrolling works even at the very edge of the window.

Anyways, it still seems strange to me that the scroll area is initially wrapped in a frame and the scroll bar cannot be moved by dragging at the edge, but at least now I (and everyone searching for it) will know the solution...

Thank you, as your hint was very helpful and even after countless hours I could not figure this out myself.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tedro