PDA

View Full Version : QDateEdit change the "first day of week"



xgoan
3rd April 2008, 08:53
Hi!

How can I change the "First day of Week in a QDateEdit?

Thanks

maverick_pol
3rd April 2008, 09:06
Hi,

What do you need to do exactly?

patrik08
3rd April 2008, 09:20
Hi!

How can I change the "First day of Week in a QDateEdit?

Thanks

Is not possibel! ...
i rewrite a Widget to display all day from one Year now is a QTableWidget..

http://www.qt-apps.org/content/show.php/Multicalendar+QTableWidget?content=76026

xgoan
3rd April 2008, 11:34
:(

I want the weeks start on monday :(

wysota
3rd April 2008, 12:07
Isn't it locale dependent? BTW. Didn't you mean QCalendarWidget and not QDateEdit? The latter is just a spinbox. If you want to change settings of the calendar widget it user, you can use QDateTimeEdit::calendarWidget() and change its firstDayOfWeek property.

Raycho Raykov
23rd December 2013, 07:59
Here is a simple hack to change first day of week in QDateEdit using class inherited from QItemDelegate :



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 );
}


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.