[SOLVED] QCalendarWidget.setDateEditEnabled(bool) does nothing.
I'm trying to set a QCalendarWidget so it cannot be modified. I think that is what this method is for but it doesn't work.
Other widgets have a setReadOnly(bool) method but this one doesn't for what ever reason.
Am I doing it wrong?
do you try this?
I've created the project with QtCreator, and with these instructions an user can't modify the calendar.
MainWindow::MainWindow(QWidget *parent) :
I looked into this but there is no such function on the calendar widget, when the intellisense thing pops up. Looking at the docs also seems to confirm this. I am using 4.8.1
Also it seems the function I'm trying to use, doesn't do what the name sounds like it should, I'm new to QT so I'm not sure what it's talking about, from the docs....
dateEditEnabled : bool
This property holds whether the date edit popup is enabled.
If this property is enabled, pressing a non-modifier key will cause a date edit to popup if the calendar widget has focus, allowing the user to specify a date in the form specified by the current locale.
By default, this property is enabled.
The date edit is simpler in appearance than QDateEdit, but allows the user to navigate between fields using the left and right cursor keys, increment and decrement individual fields using the up and down cursor keys, and enter values directly using the number keys.
This property was introduced in Qt 4.3.
What happens when dateEditEnabled is set to true is that you can input a date with your keyboard to change the date displayed on the calendar.
But you need to specify a bit what you mean with "modify the calendar widget" because I don't get whether this is what you want. The described behavior works for me.
I'm looking for the functionality that the calendar doesn't change the date when the user clicks on it. In effect is is readonly.
The other widget's in my dialog have .setReadOnly(bool) which does for those widgets exactly what I need.
I need this functionality because i have a dialog with two of these calendars one displays the old date which should never change, and the other is the one the user modifies.
Then TFabbri was right, you need to setEnabled(false) to the calendar widget. Something like
QCalendarWidget *cal = new QCalendarWidget();
dateEditEnabled controls whether the calendar widget can be edited with keyboard, while enabled controls whether the widget accepts mouse events.
Notice that enabled is a property inherited from QWidget; that's why you couldn't find it in the doc page of QCalendarWidget.
If you solve the problem, change the topic with a heading [SOLVED].