[Qt-interest] QTableView and read-only column

Bo Thorsen bo at thorsen-consulting.dk
Fri Aug 20 10:39:08 CEST 2010


Den 20-08-2010 03:54, Joel B. Mohler skrev:
> I have an editable QTableView with four columns 0-3, but column 1 only
> provides read-only feedback to the user.   I can get this implemented to be
> read-only correctly in that there is no widget given for column 1, but there's
> a usability annoyance with edit focus.
>
> If I edit column 0 and press tab, I'd like to skip directly to column 2 which
> is the next editable column.  Instead the table flips out of edit mode and
> selects the cell in column 1.  Worse yet, when I tab to column 2 I stay out of
> edit mode which I find to be rather jarring visually.  I do realize that I can
> just begin typing in column 2 and it will toggle back to edit mode, but the
> visual cues for that are lacking.
>
> What can I do to attain the following goals?
> Ideal:  I'd like to skip column 1 and go directly to column 2 on tab.
> Acceptable:  Maintain edit mode when I get focus back to column 2.
>
> Here's the code for my model's flag method (actually PyQt, but I doubt that
> matters to the answer):
>
>      def flags(self,index):
>          result = QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled
>          c = self.columns[index.column()]
>          if not self.readonly or getattr(self.cls,c).readonly:
>              result |= QtCore.Qt.ItemIsEditable
>          return result

How about not returning ItemIsSelectable on that column?

If it should be selectable, but just not in this case, then it's not a 
usability problem. Instead, skipping it on the tab would be a usability 
problem.

Bo Thorsen.




More information about the Qt-interest-old mailing list