Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Error: ‘class QLabel’ has no member named ‘dateTime’???
Forum Updated to NodeBB v4.3 + New Features

Error: ‘class QLabel’ has no member named ‘dateTime’???

Scheduled Pinned Locked Moved C++ Gurus
2 Posts 2 Posters 2.8k Views 1 Watching
  • 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.
  • Y Offline
    Y Offline
    yaboinav
    wrote on last edited by
    #1

    Terminal errors:
    test.cpp: In member function ‘void Press::Save()’:
    test.cpp:107:50: error: ‘class QLabel’ has no member named ‘dateTime’
    test.cpp:108:52: error: ‘class QLabel’ has no member named ‘dateTime’
    test.cpp:109:56: error: ‘class QLabel’ has no member named ‘currenttext’
    test.cpp:110:54: error: ‘class QLabel’ has no member named ‘toPlainText’
    test.cpp:113:24: error: ‘class QLabel’ has no member named ‘setCurrentIndex’
    test.cpp:114:21: error: ‘class QLabel’ has no member named ‘setDateTime’
    test.cpp:115:22: error: ‘class QLabel’ has no member named ‘setDateTime’
    test.cpp: At global scope:
    test.cpp:118:15: error: found ‘:’ in nested-name-specifier, expected ‘::’
    test.cpp: In member function ‘void Press::Discard()’:
    test.cpp:120:24: error: ‘class QLabel’ has no member named ‘setCurrentIndex’
    test.cpp:121:21: error: ‘class QLabel’ has no member named ‘setDateTime’
    test.cpp:122:22: error: ‘class QLabel’ has no member named ‘setDateTime’
    make: *** [test.o] Error 1

    test.cpp:

    @
    void Press::Save(){
    QString filename="test.txt";
    QFile file(filename);
    if (file.open(QIODevice::WriteOnly))
    {
    QTextStream stream(&file);
    QString startboxstring = startLabel->dateTime().toString("dd.MM.yyyy hh.mm");
    QString finishboxstring = finishLabel->dateTime().toString("dd.MM.yyyy hh.mm");
    QString locationboxstring = locationLabel->currenttext();
    QString summaryboxstring = summaryLabel->toPlainText();
    stream << startboxstring.toAscii()<<"/n"<< finishboxstring.toAscii()<<"/n"<<locationboxstring.toAscii()<<"/n"<<summaryboxstring.toAscii();
    }
    locationLabel->setCurrentIndex(0);
    startLabel->setDateTime(QDateTime::currentDateTime());
    finishLabel->setDateTime(QDateTime::currentDateTime().addSecs(3600));
    }

    void Press:Discard()
    {   
        locationLabel->setCurrentIndex(0);
        startLabel->setDateTime(QDateTime::currentDateTime());
        finishLabel->setDateTime(QDateTime::currentDateTime().addSecs(3600));
    
    }   
    

    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are trying to call methods from various unrelated widgets on QLabel widgets.

      e.g. dateTime is a function from QDateTimeEdit.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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