Undefined interface Q_INTERFACES(QGraphicsItem)



  • Hello Qt forum

    I have created a vs2012 dll project which uses Qt library on windows platform. I have a QgraphicView that hold elements (widgets) and perform some animation with them. However I want to use Q_INTERFACES macro in on of my classes that inherits from QgraphicsItem but I get the following error:

    error : Undefined interface
    

    How can I define this macro and where to define it in my project?

    Thanks in advance!

    Massi


  • Moderators

    Can you provide some more info, preferably some code sample?

    Some general info is in the docs: link and link.



  • QGraphicsItem is not interface. I'm assuming that you are developing a plugin. You can look at the Qt Assistant for "How to create Qt plugin". You can look for topics "The Low-Level API: Extending Qt Applications". It start with defining your own interface and implementing this interface.



  • Many thanks for your quick reply!

    Well, I'm refactoring a Qt mingw code to Qt visual studio 2012. I have a C++.net dll project and I'm using Qt to display graphics widget. I'm not familiar with Q_INTERFACES macro and I'm not creating a Qt plugin either. Basically, I just have a class that inherit from QGraphicItems and QObject class. Since I'm using vs2012 and I had to handle moc file manually, I'm wondering if it might be the source cause of my issue?

    class SupperClass : public QObject, public QGraphicsItem
    {
           Q_OBJECT
           Q_INTERFACES(QGraphicsItem)
    public:
      	// Animation function (from graphics item)
    	void advance(int p_step);
    private:
            // members
    }
    class GraphicsView : public QGraphicsView
    {
          Q_OBJECT
    public:
          GraphicsView() {
             m_timer = new QTimer(this);
    	 connect(m_timer, SIGNAL(timeout()), m_scene, SLOT(advance()));
           }
    private:
          QTimer * m_timer;
    }
    

    Again thanks for your time and help!!

    Massi


  • Lifetime Qt Champion

    Hi,

    There's no need for that combo, Qt provides QGraphicsObject. And like @dheerendra wrote already, Q_INTERFACES only makes sense in a plugin project.



  • @SGaist Many thanks for the info!!!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.