PDA

View Full Version : setColumnReadOnly and setFocusStyle in qt4 QTableWidget?



darshan.hardas
29th October 2007, 07:42
I was using Q3Table. Now I want to use QTableWidget
My code was

q3Table->setColumnReadOnly(0, true);
q3Table->setColumnReadOnly(2, true);
q3Table->setColumnReadOnly(3, true);
q3Table->setColumnReadOnly(5, true);

Now I want to port this to qt4 So if I do

q4TableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers) ;

All coulmns will be readOnly, so how I should do it? :eek:

Also while porting from qt3 to qt4 i have

q3Table->setFocusStyle(Q3Table::FollowStyle);

Can you suggest me what would be the equivalent code for both ? :crying:

wysota
29th October 2007, 09:31
To make an item read only you have to make sure QTableWidgetItem::flags() doesn't return ItemIsEditable or ItemIsEnabled, depending on the effect you want to achieve. You can set the flags for a particular item with QTableWidgetItem::setFlags(). I also suggest to consider switching to a model based approach if you are trying to make something complex.