QTabWidget: how to implement MRU Ctrl+Tab switching ?
Unsolved
General and Desktop
-
wrote 8 days ago last edited by
I am using a QTabWidget in my application, and while the default Ctrl+Tab cycles through tabs linearly, I would like to implement a "most recently used" (MRU) switching behavior, similar to what users experience in browsers like Firefox or IDEs like CLion / IntelliJ IDEA.
My desired functionality for Ctrl+Tab is as follows:
- quick Press/Release: A standard, quick press and release of Ctrl+Tab should switch focus directly to the immediately preceding (most recently used) tab.
- hold Ctrl, Press Tab Repeatedly: When Ctrl is held down and Tab is pressed:
- A popup should appear, listing the tabs ordered by most recently used.
- Subsequent presses of Tab (while Ctrl is held) should cycle forward through this MRU list.
- Shift+Ctrl+Tab should cycle backward through the MRU list.
- Releasing the Ctrl key should activate the tab currently selected in the popup list.
-
wrote 8 days ago last edited by
FWIW, if there is no Qt direct solution then you should be able to work out the logic and build it manually, by catching the relevant framework events to determine last/next tab and manage a queue of them.
-
wrote 7 days ago last edited by
Need new class sub-classing QTabWidget
MruTabWidget::MruTabWidget(QWidget *parent) : QTabWidget(parent)
and
installEventFilter
1/3