QTabWidget has an opportunity to move tabs via setMovable(true) function.
I would like to reimplement some logic to have an ability of scrolling while user moves tab outside visible area.
For example in FireFox when user move tab on left or right arrow of tabbar it scrolles so that user could place it on the right of non visible previously area.
I tried to override mouseMoveEvent from QTabBar like this:
It's qtjambi, but i guess the main idea could be caught 
@Override
protected void mouseMoveEvent
(final
QMouseEvent event
) { if (!event.button().equals(EStandardButton.NoButton)) {
if (event.pos().x() >= this.pos().x() + this.width()) {
if (rightBtn.isEnabled() && !rightBtn.isDown()) { //rightButton is a triangle button for scroll right which was found earlier
rightBtn.setDown(true);
}
} else if (event.pos().x() <= 0) {
if (rightBtn.isDown()) {
rightBtn.setDown(false);
}
if (leftBtn.isEnabled() && !leftBtn.isDown()) {
leftBtn.setDown(true);
}
} else { //in the middle
if (rightBtn.isDown()) {
rightBtn.setDown(false);
}
if (leftBtn.isDown()) {
leftBtn.setDown(false);
}
super.mouseMoveEvent(event);
}
} else {
super.mouseMoveEvent(event);
}
}
@Override
protected void mouseMoveEvent(final QMouseEvent event) {
if (!event.button().equals(EStandardButton.NoButton)) {
if (event.pos().x() >= this.pos().x() + this.width()) {
if (rightBtn.isEnabled() && !rightBtn.isDown()) { //rightButton is a triangle button for scroll right which was found earlier
rightBtn.setDown(true);
}
} else if (event.pos().x() <= 0) {
if (rightBtn.isDown()) {
rightBtn.setDown(false);
}
if (leftBtn.isEnabled() && !leftBtn.isDown()) {
leftBtn.setDown(true);
}
} else { //in the middle
if (rightBtn.isDown()) {
rightBtn.setDown(false);
}
if (leftBtn.isDown()) {
leftBtn.setDown(false);
}
super.mouseMoveEvent(event);
}
} else {
super.mouseMoveEvent(event);
}
}
To copy to clipboard, switch view to plain text mode
The main problem that during the scroll event there is no mouseMoveEvent, so movable tab stay on it's start position when start scrolling.
In the end of scrolling tab which was moved could not be seen.
I would like to implement FF behaviour.
Bookmarks