Search code examples
c++qtqwidget

Adding a scrollbar to a custom QWidget


I have a custom QWidget A, which contains another custom QWidget B. I want to add a scrollbar to the Qwidget B. I tried adding a QScrollArea, but it covers the entire window of QWidget A. How do I ensure that the scrollbar is for only QWidget B?


Solution

  • First replace QWidget B with the QScrollArea and set it up so that it is where you want it to be. Then simple add QWidget B to the QScrollArea.