PDA

View Full Version : Tab Order is Not Working



kavinsiva
18th June 2010, 06:15
HI,
In My code i set some tab order but it doesnt works pls guide me to resolve this



mainwindow.cpp


#include "mainwindow.h"
#include<QtGui>


MainWindow::MainWindow(QWidget *parent) : QDialog(parent)
{
buttonBox = new QDialogButtonBox(this);
buttonBox->setGeometry(QRect(170, 90, 181, 34));
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialo gButtonBox::Save);

groupBox = new QGroupBox(this);
groupBox->setGeometry(QRect(10, 10, 141, 80));

RB1= new QRadioButton(groupBox);
RB1->setGeometry(QRect(10, 10, 121, 19));
RB1->setText("Absalute Time");
RB1->setChecked(true);
RB1->setFocus();


RB2 = new QRadioButton(groupBox);
RB2->setGeometry(QRect(10, 40, 111, 19));
RB2->setText("Relative Time");

CB1= new QComboBox(this);
CB1->setGeometry(QRect(170, 20, 78, 24));
CB1->addItem("1");
CB1->addItem("2");
CB1->addItem("3");
CB1->addItem("4");

CB2 = new QComboBox(this);
CB2->setGeometry(QRect(270, 20, 78, 24));
CB2->addItem("1");
CB2->addItem("2");
CB2->addItem("3");
CB2->addItem("4");

CB3 = new QComboBox(this);
CB3->setGeometry(QRect(170, 50, 78, 24));
CB3->addItem("1");
CB3->addItem("2");
CB3->addItem("3");
CB3->addItem("4");

QWidget::setTabOrder(CB1,CB2);
QWidget::setTabOrder(CB2,buttonBox);
QWidget::setTabOrder(CB3,buttonBox);

}


Regards:

aamer4yu
18th June 2010, 07:15
What doesnt work and what do you expect ?

kavinsiva
18th June 2010, 07:21
Hi,

#
QWidget::setTabOrder(CB1,CB2);
#
QWidget::setTabOrder(CB2,buttonBox);
#
QWidget::setTabOrder(CB3,buttonBox);

The Above code is not working.By Pressing arrow keys the focus doent move from CB1 to CB2

Regards

aamer4yu
18th June 2010, 07:29
The focus moves by pressing 'Tab' key !!
not arrow keys ...
The function name itself says something :rolleyes:

kavinsiva
18th June 2010, 07:45
But i want to change the focus through Arrow keys pls Guide me to do this one

aamer4yu
18th June 2010, 08:10
Then you have to catch key press event in the parent widget, and use QWidget::focusNextChild to move the focus.

SixDegrees
18th June 2010, 12:01
You also need to think carefully about why you would do such a thing. Users become accustomed to keyboard navigation that follows standards; imposing a non-standard way to navigate through a GUI is possible, but is often frustrating for users and therefore not a good idea.

To be sure, there are exceptions to everything, but you should think very carefully before inventing your own navigational paradigm.