Results 1 to 5 of 5

Thread: How to default Date-Edit Widget to system date

  1. #1
    Join Date
    Dec 2006
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face How to default Date-Edit Widget to system date

    I have just discovered Qt!. I have been looking at all of its wonderful features. In designing my first program using Designer I selected the Date-Edit Widget but can find no way to set its default value to the current system date. Do I have to do this programatically? Same question for Time-Edit Widget.

  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: How to default Date-Edit Widget to system date

    Quote Originally Posted by JohnToddSr View Post
    I have just discovered Qt!. I have been looking at all of its wonderful features.
    First of all, congratulations for such a great pick!

    Quote Originally Posted by JohnToddSr View Post
    In designing my first program using Designer I selected the Date-Edit Widget but can find no way to set its default value to the current system date. Do I have to do this programatically? Same question for Time-Edit Widget.
    Yes, you have to do it programmatically:
    Qt Code:
    1. dateEdit->setCurrentDate(QDate::currentDate());
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Dec 2006
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to default Date-Edit Widget to system date

    Thanks, for the input but...Ok, I guess I'm a little slow on getting this.

    Here's my code:

    Qt Code:
    1. MainWindow::MainWindow( QWidget* parent ) : QMainWindow( parent )
    2. {
    3. setupUi( this );
    4. frame_Top->hide();
    5. tabWidget->hide();
    6. dateEdit_tabDetail->setCurrentDate(QDate::currentDate());
    7. }
    To copy to clipboard, switch view to plain text mode 

    Within Designer I have named my QObject objectName: dateEdit_tabDetail.
    So in my instance I would assume the following applies:
    Your example:
    Qt Code:
    1. dateEdit->setCurrentDate(QDate::currentDate());
    To copy to clipboard, switch view to plain text mode 

    becomes

    Qt Code:
    1. dateEdit_tabDetail->setCurrentDate(QDate::currentDate());
    To copy to clipboard, switch view to plain text mode 

    Obviously that is not all there is to it.
    I get the following error:

    MainWindow.cpp:27:
    error: 'class QDateEdit' has no member named 'setCurrentDate'

    What am I missing? (besides a brain)
    Last edited by wysota; 18th January 2007 at 10:41. Reason: missing [code] tags

  4. #4
    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: How to default Date-Edit Widget to system date

    Quote Originally Posted by JohnToddSr View Post
    I get the following error:

    MainWindow.cpp:27:
    error: 'class QDateEdit' has no member named 'setCurrentDate'

    What am I missing?
    Sorry. Obviously it's "setDate()", not "setCurrentDate()". See QDateTimeEdit::setDate() for details (QDateEdit inherits QDateTimeEdit).
    Qt Code:
    1. dateEdit_tabDetail->setDate(QDate::currentDate());
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. #5
    Join Date
    Dec 2006
    Posts
    23
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to default Date-Edit Widget to system date

    Thanks, lots!!! Works as advertised!

Similar Threads

  1. Replies: 4
    Last Post: 24th March 2006, 23:50

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.