Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

How to create a Component that also derives from the QObject class

2 posters

Go down  Message [Page 1 of 1]

feri



HI
First of all, congratulations on the new site and forum.
I noticed that in version 1.1.0 the Components no longer derive from the QObject class, is it possible to create a Component that also derives from the QObject class and possibly how can I do it.
Thank you
Greetings

arcachofo

arcachofo

First of all, congratulations on the new site and forum.
Thank you.

I noticed that in version 1.1.0 the Components no longer derive from the QObject class, is it possible to create a Component that also derives from the QObject class and possibly how can I do it.
just derive it from QOject.
For example;
Code:
class MyClass : public QObject

feri



I wanted to do something like this:

Code:

// prova.h

#ifndef PROVA_H
#define PROVA_H

#include "e-clocked_device.h"
#include "component.h"
#include <QObject>

class LibraryItem;
class QObject;

class  Prova : public Component, public eClockedDevice, public QObject
{
    Q_OBJECT
    public:
        Prova( QString type, QString id );
        ~Prova();
       
        static Component* construct( QString type, QString id );
        static LibraryItem* libraryItem();

        virtual void stamp() override;
   
    private:
   
};

#endif




// prova.cpp

#include "itemlibrary.h"
#include <QObject>

Component* Prova::construct( QString type, QString id )
{
    return new Prova( type, id );
}

LibraryItem* Prova::libraryItem()
{
    return new LibraryItem(
        "Prova",
        "Modules",
        "prova.png",
        "Prova",
        Prova::construct );
}

Prova::Prova( QString type, QString id )
      : Component( type, id )
      , QObject (nullptr)
      , eClockedDevice( id )

{
  // . . . . . . .
}

Prova::~Prova() {}

void Prova::stamp() {}

#include "moc_prova.cpp"

But I get compilation errors.
Greetings

arcachofo

arcachofo

But I get compilation errors.
Then something must be wrong...

feri



I can not make it.
I can't use signal and slot can you help me?
Greetings

arcachofo

arcachofo

But I get compilation errors.
Look at the error message and fix it.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum