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

compiling error: convertion from QObject base to derived type

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 4.8.1
    • None
    • Ubuntu 12.04

    Description

      During compiling there every time a error occurs while compiling moc file. It happpens because

      *_t = static_cast< ... >
      

      is used. I think there should be written dynamic_cast. I also attached the moc file.

      error message:

      moc_my_header.cpp: In static member function 'static void MyNamespace::MyInterface::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)':
      moc_my_header.cpp:48: error: cannot convert from base 'QObject' to derived type 'MyNamespace::MyInterface' via virtual base 'QObject'
      

      Here my example code:

      #ifndef MY_HEADER_H
      #define MY_HEADER_H
      
      #include <QObject>
      #include <QString>
      
      
      namespace MyNamespace {
      
      
          class MyInterface : virtual public QObject {
      
              Q_OBJECT
      
              public:
                virtual void setData(QString data) = 0;
      
              signals:
                void editSomething(QString name);
      
          };
      
      
      }
      
      Q_DECLARE_INTERFACE(MyNamespace::MyInterface, "MyInterface.lib.MyInterface")
      
      #endif // MY_HEADER_H
      
      
      

      Attachments

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

        Activity

          People

            thiago Thiago Macieira
            anno Hans Müller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes