does different editors means the same thing that i need, i.e., combo in one column and spinbox in other ?Originally Posted by jpn
how can i set editor for different inedxes ?
can't the different delegate be used for different columns ?
does different editors means the same thing that i need, i.e., combo in one column and spinbox in other ?Originally Posted by jpn
how can i set editor for different inedxes ?
can't the different delegate be used for different columns ?
Do what u r afraid to do, and the death of fear is sure.
Create a combo or spin box according to the model index column. Something like:Originally Posted by ankurjain
Just be aware that then you need to check which column is in question and cast to appropriate widget in setEditorData() and setModelData()...Qt Code:
QWidget* SpinBoxDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == something) { ... return editor; } else { ... return editor; } }To copy to clipboard, switch view to plain text mode
Unfortunately nope. A single item delegate can be set for the whole view and it's model.can't the different delegate be used for different columns ?
J-P Nurmi
thanks JPN Brother ....
hey can u tell me how can i make myself conceptually more clear for qt. i find the tuts ( the desrciption ) somewhat insufficient ( not totally targeted towards brginners ).
ne resources ??
Do what u r afraid to do, and the death of fear is sure.
Hi All,
This is my first post, by the way, I salute everyone.
I don't know QT very much, i'm just started few weeks ago.
Is there any way to achieve that trick by using QTableWidget / QTableWidgetItem ?
I read a tutorial about a QT3 QTable / QTableItem where it's seems to be achievable!
Use of QTableWidget::addItem ( int row, int column, QTableWidgetItem * qtwItem ) could be useful?
Last edited by KekraU; 17th May 2006 at 23:17.
If you are looking for different kinds of editors, you can use a custom item delegate with QTableWidget as well. Just be aware that the "default item delegate" QItemDelegate already offers through the QItemEditorFactory a few different editor widgets for different types of data:Originally Posted by KekraU
- QComboBox for booleans
- QSpinBox for integers (both signed and unsigned)
- QDoubleSpinBox for doubles
- QDateTimeEdit for datetimes
- QDateEdit for dates
- QTimeEdit for times
(- QLabel for pixmaps)
- QLineEdit otherwise
A common mistake is to insert all data as text. By this way you'll end up always having a QLineEdit as the editor. You can use the method QTableWidgetItem::setData() to set different kinds of data for an item.
If you just want to place some widgets persistently in the cells, you may use cell widgets.
J-P Nurmi
hi kekrau,Originally Posted by KekraU
i m using qt-4.1.2 but i can't find the function that u mentioned in qtablewidget.![]()
Thanx jpn for giving idea to use cellWidget![]()
Last edited by ankurjain; 18th May 2006 at 07:34.
Do what u r afraid to do, and the death of fear is sure.
Thxs JPN.
I have already looked at these Editors...
I think the main point with these Editors (you mentionned) that they could be use outside TableView... to edit these kind of data (Time, Date, DateTime, Integer, and so on...) in QTableView/QTableWidget you have to include in your class which inherite from QItemDelegate, these editors.
And in fact, that is what I did to solve my problem... include Q[Editor] (ComboBox / SpinBox...) in my cell depending on the type I want to edit.
Plus, i used QTableWidget to setBackGroundColor... Really funny SpinBox on Red Background
@Ankurjain:
In fact, I search on the website, and I did not find QTableWidget::addItem, but on my 4.1.0 I have it.... But you got QTableWidget::setItem( int row, int column, QTableWidgetItem * item ) which has the same prototype and seems to do the same as previous addItem
Your link![]()
Last edited by KekraU; 18th May 2006 at 19:51.
Bookmarks