Here is a simple hack to change first day of week in QDateEdit using class inherited from QItemDelegate :
{
if ( index.column() == 1 || index.column() == 6 )
{
de->setCalendarPopup ( true );
QCalendarWidget *cw
= const_cast<QCalendarWidget
*>
( de
->calendarWidget
() );
cw->setFirstDayOfWeek ( Qt::Monday );
return de;
}
}
QWidget *MyDateDelegate::createEditor ( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
if ( index.column() == 1 || index.column() == 6 )
{
QDateEdit *de = new QDateEdit ( parent );
de->setCalendarPopup ( true );
QCalendarWidget *cw = const_cast<QCalendarWidget*> ( de->calendarWidget() );
cw->setFirstDayOfWeek ( Qt::Monday );
return de;
}
return QItemDelegate::createEditor ( parent, option, index );
}
To copy to clipboard, switch view to plain text mode
It is not an example of good practice to remove const, but it works.
You must change the index of collumn(s) where QDateEdit will appear.
You should also implement setEditorData, setModelData, updateEditorGeometry, etc. according to your vision.
Bookmarks