[Qt-interest] QTableView and read-only column
Joel B. Mohler
joel at kiwistrawberry.us
Fri Aug 20 22:23:23 CEST 2010
On Friday, August 20, 2010 04:39:08 am Bo Thorsen wrote:
> 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.
Yes, I see what you are saying. I changed my code to read
def flags(self,index):
result = QtCore.Qt.ItemIsEnabled
c = self.columns[index.column()]
if not self.readonly or getattr(self.cls,c).readonly:
result |= QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable
return result
but the resulting action seems entirely the same. That simply perplexes me so
I'm going to have to investigate this a little more closely, but that will
have to wait till tomorrow I suspect.
--
Joel
More information about the Qt-interest-old
mailing list