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
Forum Update on Monday, May 27th 2025

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 12 Mar 2016, 15:05 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 12 Mar 2016, 15:11 last edited by
      #2
      int year = QDate::currentDate().year();
      
      G 1 Reply Last reply 12 Mar 2016, 15:46
      2
      • A asanka424
        12 Mar 2016, 15:11
        int year = QDate::currentDate().year();
        
        G Offline
        G Offline
        gabor53
        wrote on 12 Mar 2016, 15:46 last edited by
        #3

        @asanka424
        Thank you.

        1 Reply Last reply
        0

        1/3

        12 Mar 2016, 15:05

        • Login

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