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? -
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? -
@IknowQT What does: I'd like to connect the scrollbar directly to the qlistwidget ? Could you explain better, what new behavior do you expect? Your question is unclear.
-
@IknowQT Looks like you have an XY problem, could you please provide a picture of what you want to get? In which part of the scrollbar do you want the image?
-
-
-
@IknowQT The big question is why don't you want the QScrollbar that comes with the QListWidget? Why do you need to replace it? What advantage or novelty do you plan to obtain with this new QScrollBar?

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.
-

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.
-

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 From what I understand (since you are not explicit in your explanation) is that you have 2 QListWidget (A and B) and you want the same QScrollBar to serve both at different times, am I correct?
yes
We need to control two widgets with one scroll. -
yes
We need to control two widgets 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.
-
@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.
When you click B, you can update the scroll according to the current location of B's selected item.
-
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.

