PDA

View Full Version : QTablewidget: how to select row with single click instead of double click?



Tiansen
5th June 2009, 08:50
Hello,

I have QTableWidget in my UI, but I have a problem, because I cannot select a row with single click, but only with double click (selectionBehavior is selectRows). I tried with cellClicked(int, int) signal, but with no success. How can I solve that?

wysota
5th June 2009, 09:12
Please provide a minimal compilable example reproducing the problem.

aamer4yu
5th June 2009, 09:23
If you are talking about editing the item on single click, instead of double click, then have a look at QAbstractItemView::setEditTriggers
Otherwise, the row or cell should be selectable on single click only.

Tiansen
5th June 2009, 09:35
Hm, I use Qt Creator to build a program. I use QTableWidget, cells are filled with QLabel (setCellWidget). Maybe I have a problem because single click is intercepted by that QLabels that reside inside table cells? How can I connect these signals, so that qtablewidget receives them?

aamer4yu
5th June 2009, 09:50
Why are you using QLabel :eek: Is there some extra rendering with the label ?
I dont see much use of using QLabel as a cell Widget... you could always use delegates to render simple text in a different way

Tiansen
5th June 2009, 10:10
I use QLabel because I use some HTML formatted text and/or images inside cells, so I think that QLabels are natural choice, or am I missing something?

wysota
5th June 2009, 10:38
Yes, you are missing something. We don't use widgets inside ItemViews, at least we try not to. Your widget is not part of the model nor part of the view thus all the functionality of ItemViews will not work with it. Search the forum for an implementation of a delegate rendering a QTextDocument.