Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting current year
QtWS25 Last Chance

Getting current year

Scheduled Pinned Locked Moved Solved General and Desktop
qdate
3 Posts 2 Posters 7.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gabor53
    wrote on last edited by
    #1

    Hi,
    I'm trying to get the date out of QDate using the following code:

    
    	QDate *year = new QDate;
        year = QDate::year ();
        qDebug() << "Year : " << year;
    
    

    I get the following error message:
    C:\Programming\Qtsamples\Date\mainwindow.cpp:11: error: cannot call member function 'int QDate::year() const' without object
    year = QDate::year ();
    ^
    What would be the correct way of doing this?
    Thank you.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      asanka424
      wrote on last edited by
      #2
      int year = QDate::currentDate().year();
      
      G 1 Reply Last reply
      2
      • A asanka424
        int year = QDate::currentDate().year();
        
        G Offline
        G Offline
        gabor53
        wrote on last edited by
        #3

        @asanka424
        Thank you.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved