qlistwidget vertical scrollbar
-
Hi, friends. I have a question about qlistwidget.
I have this property set to Always off. setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff)
I'd like to connect the scrollbar directly to the qlistwidget instead of the scrollbar that you provide, is there any way? -
The final UI composition I want to do is this screen.
If I click A UI and scroll, it will scroll through the contents of A UI, right?
If you click on B UI and scroll, I want the contents of B UI to scroll.I want to control the A, B UI with one scroll.
-
@IknowQT I see problems in what you indicate, to be didactic I will use the terminology that Qt provides in the docs:
Suppose that what you want has already been implemented, suppose also that each QListWidget has 1000 items, and is in the initial state where the "slider" is at the top touching the top "scroll arrow", and now it is in the mode of the that QScrollBar drives "A" and you slide the QScrollBar towards its lowest position so the "slider" will be touching the "scroll arrow" below so now you select "B", what should happen to the slider? What is because if you indicate that the "slider" should be kept down, then the elements of "B" will no longer be visible.
-
Self-advice
m_pScroller = new QCustomScrollBar(QCustomScrollBar::ScrollType::MAIN, Qt::Orientation::Vertical, this); this->ui.listWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); this->ui.listWidget->setVerticalScrollBar(m_pScroller);
You can create a class that inherits scrollbar and put the class that you created into a vertical scrollbar.
A and B listWidget are both set vertical scrollbar, so both widgets will be available.