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. SOLVED: error: no match for ‘operator=’
QtWS25 Last Chance

SOLVED: error: no match for ‘operator=’

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 5.8k 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.
  • J Offline
    J Offline
    johnmerlino
    wrote on last edited by
    #1

    I am getting the following error:

    /home/myuser/program/MyGateway/protocol/iridium/mailbox.cpp: In member function ‘QList<InmarsatMessage> IridiumMailbox::getInmarsatMessages()’:
    /home/myuser/program/MyGateway/protocol/iridium/mailbox.cpp:171:54: error: no match for ‘operator=’ in ‘msg.InmarsatMessage::time = inmarsat_time.QDateTime::setTimeSpec((Qt::TimeSpec)1u)’
    /home/myuser/program/MyGateway/protocol/iridium/mailbox.cpp:171:54: note: candidate is:
    /usr/include/qt4/QtCore/qdatetime.h:225:16: note: QDateTime& QDateTime::operator=(const QDateTime&)
    /usr/include/qt4/QtCore/qdatetime.h:225:16: note: no known conversion for argument 1 from ‘void’ to ‘const QDateTime&’

    It's about this line of code right here:

    QDateTime inmarsat_time = QDateTime::fromString(message->received().toString(), "ddd MMM d HH:mm:ss yyyy");

    That function received() is here:

    QDateTime ImapMessage::received (void) const {
    return(d->received);
    }

    Any idea why I am getting this error?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi,

      Your error line is
      @
      msg.InmarsatMessage::time = inmarsat_time.QDateTime::setTimeSpec((Qt::TimeSpec)1u)
      @

      That's not valid C++. What is your goal here?

      [quote]
      @
      QDateTime inmarsat_time = QDateTime::fromString(message->received().toString(), “ddd MMM d HH:mm:ss yyyy”);
      @
      [/quote]This line is valid. But why do you convert a QDateTime to QString, and then convert it back to QDateTime again?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • J Offline
        J Offline
        johnmerlino
        wrote on last edited by
        #3

        But there is no line of code as such:

        msg.InmarsatMessage::time = inmarsat_time.QDateTime::setTimeSpec((Qt::TimeSpec)1u)

        That error is pointing to this line of code:

        QDateTime inmarsat_time = QDateTime::fromString(message->received().toString(), “ddd MMM d HH:mm:ss yyyy”);
        
        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          Please use "code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 to structure your post.
          Code wrappings improve reading of your code and error listing sections significantly.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            [quote]But there is no line of code as such:
            msg.InmarsatMessage::time = inmarsat_time.QDateTime::setTimeSpec((Qt::TimeSpec)1u)[/quote]You're right; I didn't realize GCC expands code in its error messages.

            [quote]That error is pointing to this line of code:
            QDateTime inmarsat_time = QDateTime::fromString(message->received().toString(), “ddd MMM d HH:mm:ss yyyy”);[/quote]
            Hmm, I can't see any errors in that line. What is your compiler version?

            Anyway, why do you call toString() and then fromString() again? Just assign message->received() directly to inmarsat_time. Your code will be simpler, and the error might go away.

            P.S. I agree with koahnig. Your code and errors were hard to read.

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            0
            • J Offline
              J Offline
              johnmerlino
              wrote on last edited by
              #6

              So I was able to make the error go away by changing this:

              @ QDateTime inmarsat_time = message->received();
              msg.time = inmarsat_time.setTimeSpec(Qt::UTC);
              @
              to this:

              @ QDateTime inmarsat_time = message->received();
              msg.time.setTimeSpec(Qt::UTC);@

              Why does the latter work and not the former?

              1 Reply Last reply
              0
              • JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote on last edited by
                #7

                [quote]That error is pointing to this line of code:
                QDateTime inmarsat_time = QDateTime::fromString(message->received().toString(), “ddd MMM d HH:mm:ss yyyy”);[/quote]The error was NOT pointing to the line above. It was pointing to this one:
                [quote]
                @msg.time = inmarsat_time.setTimeSpec(Qt::UTC);@
                [/quote]setTimeSpec() returns void. You can't assign void to msg.time

                Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  johnmerlino
                  wrote on last edited by
                  #8

                  ok didn't realize setTimeSpec() returned void.

                  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