Results 1 to 3 of 3

Thread: QDateEdit read-only with calendar not r.o.

  1. #1
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QDateEdit read-only with calendar not r.o.

    Hi
    When dateEditInstance->setReadOnly(true) is executed,
    the dateEdit can not be changed by entering digits. This is ok.
    But as the calendar was showable, it is still shown if user clicks
    on the button. Can still be ok, but user should not be able
    to change the date, in any way. Right ? As of 4.2.2, the user can
    do it by the way of the calendar.
    Anyone have noticed this behaviour ?
    I've seen no bugs filed for this at the moment on trolltech task tracker.
    Anyone can think of a lightest workaround ?
    I'd say forbid calendar popup when set read-only false.
    Thanks in advance.

    Laurent G.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QDateEdit read-only with calendar not r.o.

    To be able to show a read only calendar popup seems to require an ugly hack, but here it is..
    Qt Code:
    1. class ReadOnlyDateEdit : public QDateEdit
    2. {
    3. public:
    4. ReadOnlyDateEdit(QWidget* parent = 0)
    5. : QDateEdit(parent), disconnected(false)
    6. {
    7. }
    8.  
    9. protected:
    10. void mousePressEvent(QMouseEvent* event)
    11. {
    12. QDateEdit::mousePressEvent(event);
    13. if (!disconnected && calendarPopup())
    14. {
    15. QWidget* popup = findChild<QWidget*>("qt_datetimedit_calendar");
    16. if (popup)
    17. {
    18. qDebug() << disconnect(popup, SIGNAL(newDateSelected(QDate)), this, SLOT(setDate(QDate)));
    19. qDebug() << disconnect(popup, SIGNAL(hidingCalendar(QDate)), this, SLOT(setDate(QDate)));
    20. qDebug() << disconnect(popup, SIGNAL(activated(QDate)), this, SLOT(setDate(QDate)));
    21. }
    22. }
    23. }
    24.  
    25. private:
    26. bool disconnected;
    27. };
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    lauranger (24th January 2007)

  4. #3
    Join Date
    May 2006
    Posts
    55
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDateEdit read-only with calendar not r.o.

    ugly is really necessary to your sentence
    Thank you Jpn.

Similar Threads

  1. Clearing QDateEdit
    By jpujolf in forum Qt Programming
    Replies: 3
    Last Post: 27th July 2006, 21:19
  2. How to read line from file
    By Krishnacins in forum Newbie
    Replies: 10
    Last Post: 1st June 2006, 23:14
  3. Replies: 13
    Last Post: 1st June 2006, 14:01
  4. Problem with receiving events from QDateEdit
    By gunhelstr in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 11:21
  5. Subclassing QDateEdit
    By jamadagni in forum Qt Programming
    Replies: 6
    Last Post: 4th February 2006, 13:26

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.