(Solved) Focus in table widget
-
Hi, someone know how put the focus in a item of a table widget?
I search for something like "item(x,y)->setfocus();and one guy say that work:
@ ui->twcadastro->setItemSelected(ui->twcadastro->item(1,0),true);@
but do not work.
sorry for my terrible english!
i hope that you understand! hehehe -
Try
@
ui->twcadastro->item(1,0)->setSelected(true);
@ -
i, try, but dont work.
-
make sure your item are "selectable and enabled":http://doc.qt.nokia.com/4.7-snapshot/qt.html#ItemFlag-enum
item(1,0)->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); -
i resolve using that:
@ui->twcadastro->openPersistentEditor(twcenter->item(1,0));
ui->twcadastro->cellWidget(1,0)->setFocus();@ -
if you want to open the editor when clicking on an item or when changing the focus, you have to set the editTriggers on the tableWidget accordingly:
@
widget->setEditTriggers(QAbstractItemView::CurrentChanged);
@s.a. "EditTrigger-enum":http://doc.qt.nokia.com/4.7-snapshot/qabstractitemview.html#EditTrigger-enum
-
i want open for write . but thanks.
-
"QAbstractItemView::edit() ":/doc/qt-4.8/qabstractitemview.html#edit should do what you want.
-
thanks! =D
-
was util for me