PDA

View Full Version : QTabWidget: How to move to another page using keypoard instead mouse?



gboelter
4th February 2010, 11:40
Hi guys,

can anybody point me to a way, to switch from one page to another inside a QTabWidget using the keyboard instead the mouse? Something similar to



int n;
n = currentIndex ();
++n;

tabWidget->setCurrentIndex( n );


but using PgUp / PgDown or something similar instedt?

I have tried it with QKeyEvent and QKeySequence, but I guess the problem is, that my tabWidget don't has a focus.

Thanks in advance.

Lykurg
4th February 2010, 12:15
Install an event filter and check there for key events.

tsp
4th February 2010, 17:39
Maybe one way would be to add ampersand (&) to tab label as described in the documentation http://doc.trolltech.com/latest/qtabwidget.html#addTab i.e. to add shortcut to each tab, but if you have some issues with the focus then this might not help.

SteveH
4th February 2010, 17:44
Hi,

I use QTabWidget a lot - on Windows XP I use Control/Tab to flit between tabs - I assume this works with other Windows variants.

SteveH

gboelter
5th February 2010, 16:51
Thanks to all of you for helping me.


Maybe one way would be to add ampersand (&) to tab label as described in the documentation http://doc.trolltech.com/latest/qtabwidget.html#addTab i.e. to add shortcut to each tab, but if you have some issues with the focus then this might not help.

I have tried to install an eventFilter. It's working well but I will use the shortcuts now, like tsp has told me. I don't no, that I can use shortcuts in a tabWidget because it's not included in the settings for a tabWidget in the designer.

Ctrl-Tab, like Steve has advised is working too, but in some cases I have many pages so it's really faster to use shortcuts.

Thanks again to everybody.