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. Upgrading from qt4 to qt5
Forum Updated to NodeBB v4.3 + New Features

Upgrading from qt4 to qt5

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.3k 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.
  • W Offline
    W Offline
    wij2
    wrote on last edited by
    #1

    Recently I tried to recompile my programs (used to work fine with qmake-qt4) with qmake-qt5. I found I have to add a line 'QT+=widgets' in .pro file. Except this, my g++ compiler always issues: error: no match for ‘operator==’ (operand types are ‘QMetaObject::Connection’ and ‘bool’) and a long list of candidates follow for each "if(QObject::connect(...)==false) {/.../}" statement.

    Question1: How to fix this problem
    Question2: Is there any general HOWTO about changes from compiling qt4 programs with qmake-qt5

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

      Hi,

      Please show the connect statements you are using.

      As for the porting guide, see the related chapter in Qt's documentation.

      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
      1
      • W Offline
        W Offline
        wij2
        wrote on last edited by
        #3

        q_v4l2.cpp: In constructor ‘MainWidget::MainWidget(const char*, QWidget*, unsigned int, unsigned int)’:
        q_v4l2.cpp:64:53: error: no match for ‘operator==’ (operand types are ‘QMetaObject::Connection’ and ‘bool’)
        if(QObject::connect(m_qtmr, SIGNAL(timeout()),
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        this, SLOT(update()) )==false) {
        ~~~~~~~~~~^
        In file included from /usr/include/qt5/QtCore/qstring.h:48,
        from /usr/include/qt5/QtCore/qobject.h:47,
        from /usr/include/qt5/QtCore/qabstractanimation.h:43,
        from /usr/include/qt5/QtCore/QtCore:5,
        from /usr/include/qt5/QtWidgets/QtWidgetsDepends:3,
        from /usr/include/qt5/QtWidgets/QtWidgets:3,
        from q_v4l2.cpp:22:
        /usr/include/qt5/QtCore/qchar.h:598:30: note: candidate: ‘constexpr bool operator==(QChar, QChar)’
        Q_DECL_CONSTEXPR inline bool operator==(QChar c1, QChar c2) Q_DECL_NOTHROW { return c1.ucs == c2.ucs; }
        ^
        ~
        ....[snipped] long candidte list

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wij2
          wrote on last edited by
          #4

          The statement is like:

               if(QObject::connect(m_qtmr, SIGNAL(timeout()),
                                    this, SLOT(update()) )==false) {
                throw Error(ECONNREFUSED) ;
               }
          

          m_qtmr is a QTimer instance
          *this is a subclass of QLabel

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            QObject::connect() now returns a QMetaObject::Connection and no boolean. So you have to rewrite your statement a little bit to use the operator bool(): http://doc.qt.io/qt-5/qmetaobject-connection.html#operator-bool

            if(!QObject::connect(m_qtmr, SIGNAL(timeout()), this, SLOT(update()) ))

            Or even better use the new signal/slot syntax: https://wiki.qt.io/New_Signal_Slot_Syntax/de

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            2

            • Login

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