A few questions about QCalendarWidget.



  • I want to know some more things about working with the QCalendarWidget.
    I am a little newbie to this one so i need some help..

    1. At the MainWindow i have a QCalendarWidget and also a button. So when you press the button some of the days numbers are becoming basic. So how when the app exits, save the state of the calendar so the next time you open the app the days numbers that were in basic be again at basic without the need to press the button.

    P.S I know how to connect the appication with the QCloseEvent the problem is that i don't know hot to save the state of the calendar.

    1. How when you double click/press enter a random date, a message be shown saying "You clicked at <date that have been clicked>."

    P.S At the "doc":http://doc.qt.nokia.com/latest/qcalendarwidget.html#activated it says about it but i don't know how to connect it with the calendar widget.

    I still have some other questions but for now that's it what i want. Thanks anyway.



  • I don't know what you mean with this: "some of the days numbers are becoming basic". Could you explain what you mean by that? Do you mean "selected"?

    You can not store the state of a widget. What you can do, is store data that allows you to reconstruct it. In this case, you would probably save a series of dates. It depends on your exact goals what the best place and format for that is. If it is only to restore the application to its previous state when you start it again, then QSettings comes to mind. If you need to save and load and exchange these files between systems, you can choose any data file format you like that fits your needs. Because you don't specify that, I will refrain from giving advice on which one might work best for you.

    There is, unfortunately, no signal for double clicking, but there is one for single clicks. Perhaps you could use an eventfilter or a subclass to catch the QEvent::MouseButtonDblClick event.



  • sorry i meant bold.. ( not basic )
    The best example that i can give you is the app: Orage Calendar ( Installed at my Ubuntu ).

    Look, what i finally want to do is to create an app with a calendar which you can set some appointments to specific days... Just for fun ( I want to practise Qt )...

    So about the double click.. Could you explain a little more about the eventfilter.. ? Ok i know how to do it when you press return but what about double click?



  • QCalendarWidget supports a method to set the text formatting for a specific date. You might want to look into the docs and find that method. Setting it to bold is supported. Like I said: you'll have to come up with a method for storing your dates and other related information. I'd look into using an SQLite database for that, but you could just start with using a simple data structure like QMap<QDate, QString>. You can serialize and deserialize this to a file with QDataStream, or use QXmlStreamReader and -Writer for an XML format.

    For event filters: look into the QObject::installEventFilter documentation.



  • Sorry for the very late reply, but I do hope this helps some one. The equivalent of a double click is @void QCalendarWidget::activated ( const QDate & date ) [signal]@

    This is quite clear from the manual

    bq. This signal is emitted whenever the user presses the Return or Enter key or double-clicks a date in the calendar widget.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.