Results 1 to 3 of 3

Thread: Question about QCalendarWidget with PyQT

  1. #1
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Question about QCalendarWidget with PyQT

    Greetings to all:

    I'm fairly new to qt, but, I can't imagine going back to gtk anymore. So as a first post, a big thanks to the qt developers.

    So, on with my question...

    I've been having some problems with the QCalendarWidget, which is very
    nice, but seems to lack some documentation. I tried googling and
    looking through many mail lists, but still can't find the solution to
    my problem. I have the following code:

    ...
    dateStr = "20070101" # january 1, 2007
    date = QDate.fromString(dateStr, QString("yyyymmdd"))
    calendar.setSelectedDate(date)
    ...

    But, the calendar does not change the month,year, or day. After the
    calendar is rendered, the current date is displayed, not the selected
    date. I can force it to change the displayed
    month and year, but not the day with the following code...

    ...
    calendar.setCurrentPage(2007, 01)
    ...

    If I call the method showSelectedDate, the current day is displayed
    instead. Am I actually changing the selectedDate or do I have to do
    something else?
    Also, what method do I use so that the day(1,2,3...31) is highlighted?
    Is there some sort of 'update' method which will redraw the calendar
    with the new selectedDate?

    Regards,
    HF

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Question about QCalendarWidget with PyQT

    Have you checked if date.isValid()?

  3. The following user says thank you to wysota for this useful post:

    hf (21st April 2008)

  4. #3
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: Question about QCalendarWidget with PyQT

    Wow, thanks, I completely overlooked that. What I found was that the date format should be "yyyyMMdd" instead of "yyyymmdd". Also, for some reason, I could only get the calendar to work right with QDateTime instead of QDate. (I'm sure it's an error on my part)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.