PDA

View Full Version : QTableView doubleclick and setEditTriggers(QAbstractItemView::SelectedClicked )



JoZCaVaLLo
8th June 2011, 16:56
Hi...

I have a QTabWidget, inside 1 Tab I have a QTableView on which I have set the setEditTriggers(QAbstractItemView::SelectedClicked ).

I also have connected the doubleclick event: when I doubleclick on this TableView, I switch to the next Tab and show the required stuff... Everything is working well.

the problem is that when I doubleclick on a selectedcell... that one goes in editmode and the QCompleter::popup() is showed (even if the app already switched to the next tab).

What shoud I do, so that if I doubleClick on a selected cell, it desn't go in editmode?

JoZCaVaLLo
15th February 2012, 13:37
The QCompleter is not completely customizable, so I finished by recoding my own completer.

My class contains a QTableView, a pointer to the parent QLineEdit, and a pointer to an QAbstractTableModel.

The tricks consists on:

writing a well coded Eventfilter method for the parentLineEdit.
writing a well coded Eventfilter method for the QTableView
bind the focus of parentLineEdit and QTableView -> QTableView.setFocusProxy(parentLineEdit);
the parent of QTableView is the QMainWindow containing parentLineEdit
I moved the QTableView on the parentLineEdit->rect().bottomLeft()
You don't need to anchor the parentLineEdit: for the time you are in editMode you can move only the mainWindow, if you click anywhere else the parentLineEdit loses focus and automatically the QTableView get closed.