Results 1 to 4 of 4

Thread: QDateEdit with QCalendarWidget always shown

  1. #1
    Join Date
    Jun 2009
    Posts
    37
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QDateEdit with QCalendarWidget always shown

    Hallo!!!

    Already Googled around but no solution found... How should I modify my QDateEdit so that as soon as I get in, the QCalendarWidget gets shown???

    I tried the following, but it doesn't work...
    Qt Code:
    1. void MyDateEdit::focusInEvent(QFocusEvent * e)
    2. {
    3. QDateTimeEdit::focusInEvent(e);
    4. calendarWidget()->show();
    5. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2009
    Location
    Greece
    Posts
    69
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDateEdit with QCalendarWidget always shown

    If you need a QCalenderWidget all the time then you can use it directly without the QDateEdit. It is even available in designer.

  3. #3
    Join Date
    Jun 2009
    Posts
    37
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QDateEdit with QCalendarWidget always shown

    That's not what i need.

    I'm inside a QTableView... or even a form. I wish that the user can both write directly into the QDateEdit or click on the QCalendarWidget. But instead of having to click on the button to show the QCalendarWidget, I'd like the QCalendarWidget to be shown as soon as the QDateEdit gets focused.

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

    Default Re: QDateEdit with QCalendarWidget always shown

    There is no easy way to do what you want. Showing the calendar is easy but it's likely it will pop up in a wrong place:
    Qt Code:
    1. QWidget *popup = findChild<QWidget*>("qt_datetimedit_calendar");
    2. if(popup)
    3. popup->show();
    4. else
    5. qWarning() << "Popup not initialized";
    To copy to clipboard, switch view to plain text mode 
    so you'll have to calculate the position yourself the same way QDateTimeEdit does.

    You can force the widget to popup the calendar by sending it a key event with Qt::Key_NumberSign or Qt::Key_Select keys.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QCalendarWidget::clicked
    By ouekah in forum Newbie
    Replies: 6
    Last Post: 2nd May 2010, 16:37
  2. 2 QDateEdit with 1 QCalendarWidget ?
    By ouekah in forum Newbie
    Replies: 4
    Last Post: 26th April 2010, 09:24
  3. How can I add a QCalendarWidget to a QToolBar?
    By cydside in forum Qt Programming
    Replies: 1
    Last Post: 10th April 2009, 23:06
  4. about QCalendarWidget
    By nifei in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2009, 09:17
  5. No QCalendarWidget in designer? 4.2.0-tp1
    By Spockmeat in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2006, 18:13

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.