PDA

View Full Version : The strange behaviour of the tab order in QTableWidget class.



Mad Max
17th February 2006, 04:48
#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QTableWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDialog w;
QVBoxLayout vboxLayout;
w.setLayout(&vboxLayout);
QLineEdit edit(&w);
vboxLayout.addWidget(&edit);
QTableWidget table(&w);
table.setRowCount(1);
table.setColumnCount(3);
table.setTabKeyNavigation(false);
vboxLayout.addWidget(&table);
QLineEdit edit2(&w);
vboxLayout.addWidget(&edit2);
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}

I observe a strange behaviour of the tab order in this form. At start it has the order: edit->table->edit2, after the editing of any column the tab order change to: edit->edit2->table. Can anyone tell me why it happen? I am in the doubts :confused:

Mad Max
26th February 2006, 06:52
#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QTableWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDialog w;
QVBoxLayout vboxLayout;
w.setLayout(&vboxLayout);
QLineEdit edit(&w);
vboxLayout.addWidget(&edit);
QTableWidget table(&w);
table.setRowCount(1);
table.setColumnCount(3);
table.setTabKeyNavigation(false);
vboxLayout.addWidget(&table);
QLineEdit edit2(&w);
vboxLayout.addWidget(&edit2);
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}

I observe a strange behaviour of the tab order in this form. At start it has the order: edit->table->edit2, after the editing of any column the tab order change to: edit->edit2->table. Can anyone tell me why it happen? I am in the doubts :confused:

It is solved so:


#include <QtGui/QApplication>
#include <QtGui/QDialog>
#include <QtGui/QTableWidget>
#include <QtGui/QVBoxLayout>
#include <QtGui/QLineEdit>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QDialog w;
QVBoxLayout vboxLayout;
w.setLayout(&vboxLayout);
QLineEdit edit(&w);
vboxLayout.addWidget(&edit);
QTableWidget table(&w);
table.setRowCount(1);
table.setColumnCount(3);
table.setTabKeyNavigation(false);
vboxLayout.addWidget(&table);
QLineEdit edit2(&w);
vboxLayout.addWidget(&edit2);

w.setTabOrder(&edit, &table);
w.setTabOrder(&table, &edit2);
w.setTabOrder(&edit2, &edit);

w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}