PDA

View Full Version : QTableView currentChanged <> selecting header



Everall
5th February 2006, 17:04
Hi,

I'm experimenting a little with QTableViews selection behaviour.
The default is when you click on an item it gets selected (blue), but editing doesn't start yet. When you click on a column , the entire column gets selected (blue).

If you alter the editTrigger property for the view to CurrentChanged, then clicking on a cell starts editing immediately. Ok that's what I want.

But when you click a vertical header now, the first cell is in editing state (the delegate shows up) and that is not what I want.

Does anyone know a simple way to use the currentChanged property without getting the first cell in editing state when clicking on a header?



You can see this behaviour yourself if you want:
in the relationaltablemodel example I added a line to the createview function


QTableView *createView(const QString &title, QSqlTableModel *model)
{
QTableView *view = new QTableView;
...
view->setEditTriggers ( QAbstractItemView::CurrentChanged );
return view;
}

Maybe i'm not seeing the obvious...
All suggestions are welcome

wysota
5th February 2006, 21:00
You can remove the trigger and try:

connect(myTableView,
SIGNAL(activated(const QModelIndex &)),
myTableView,
SLOT(edit(const QModelIndex &))
);

Everall
6th February 2006, 09:10
Thanks Wysota,

for the suggestion. It certainly helped looking at it from another angle. I would never have thought about that.

I tried it with signal activated, but that didn't work. But signal clicked did the job



connect(myTableView,
SIGNAL(clicked(const QModelIndex &)),
myTableView,
SLOT(edit(const QModelIndex &))
);


Thanks a lot

Everall

kaushal_gaurav
1st April 2009, 08:09
I have a similar problem...

I need to start editing when i click on any cell in the QTableView.
I have tried setting editTriggers::Currentchanged property to 1. and also with the code


connect(myTableView,
SIGNAL(clicked(const QModelIndex &)),
myTableView,
SLOT(edit(const QModelIndex &))
);


but the issue is that the contents of the cell get selected, when i click on the cell.
I just want editing without selection of contents ans when i double click on the cell the content get selected.

Please help....
GK

kaushal_gaurav
1st April 2009, 09:24
I have a similar problem...

I need to start editing when i click on any cell in the QTableView.
I have tried setting editTriggers::Currentchanged property to 1. and also with the code



connect(myTableView,
SIGNAL(clicked(const QModelIndex &)),
myTableView,
SLOT(edit(const QModelIndex &))
);


but the issue is that the contents of the cell get selected, when i click on the cell.
I just want editing without selection of contents ans when i double click on the cell the content get selected.

Please help....
GK