Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10727

QFutureWatcher - can't cast from QObject

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: Not Evaluated Not Evaluated
    • None
    • 4.6.2
    • Core: Object Model
    • None
    • Microsoft Windows 7 Ultimate (32-bit)
      Qt SDK 2010.02.1

      Casting from QObject * to QFutureWatcher<void> * doesn't work:
      QObject *obj = qobject_cast<QObject *>(new QFutureWatcher<void>);
      QFutureWatcher<void> *watcher = qobject_cast<QFutureWatcher<void> *>(obj);

      Such a cast may be used for example from a slot that handles the finished() signal of the QFutureWatcher:
      QFutureWatcher<void> *watcher = qobject_cast<QFutureWatcher<void> *>(sender());

      When compiling, the following error is generated:
      c:\Qt\2010.02.1\qt\include/QtCore/../../src/corelib/concurrent/qfuturewatcher.h: In member function 'void QFutureWatcherBase::qt_check_for_QOBJECT_macro(const T&) const [with T = QFutureWatcher<void>]':
      c:\Qt\2010.02.1\qt\include/QtCore/../../src/corelib/kernel/qobject.h:453: instantiated from 'T qobject_cast(QObject*) [with T = QFutureWatcher<void>*]'
      mainwindow.cpp:487: instantiated from here
      c:\Qt\2010.02.1\qt\include/QtCore/../../src/corelib/concurrent/qfuturewatcher.h:61: error: void value not ignored as it ought to be

      It seems that the QFutureWatcher class is missing the Q_OBJECT macro.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            ogoffart Olivier Goffart (Woboq GmbH)
            net147 Jonathan Liu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes