Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QObject::connect: No such signal QThread::ThreadsMiniature::drowMiniature(QImage)



  • What am I doing wrong ?
    threadsminiature.h

    #ifndef THREADSMINIATURE_H
    #define THREADSMINIATURE_H
    
    #include <QThread>
    #include <QImageReader>
    #include "mainwindow.h"
    
    class ThreadsMiniature : public QThread
    {
    public:
        explicit ThreadsMiniature(QObject *parent=0, QString Path="");
    
        void run();
        QString _Path;
    signals:
        QImage drowMiniature(QImage image) {return image;}
    
    private:
        QString name; 
    };
    

    threadsminiature.cpp

    #include "threadsminiature.h"
    
    ThreadsMiniature::ThreadsMiniature(QObject *parent, QString Path) :
        QThread(parent),
        _Path(Path)
    {
    
    }
    
    void ThreadsMiniature::run()
    {
        int icoWidth    = 200;
        int icoHeight    = 200;
    
        QImageReader imageReader(_Path);
    
        QSize size;
        int image_width;
        int image_height;
    
        if (imageReader.supportsOption(QImageIOHandler::Size))
        {
            size = imageReader.size();
            image_width = size.width();
            image_height = size.height();
        }
    
        double ratio = (double)image_width / (double)image_height;
        if (ratio >= 1)
        {
            image_width = icoWidth;
            image_height = image_width / ratio;
        } else {
            image_height = icoHeight;
            image_width = image_height * ratio;
        }
    
        imageReader.setScaledSize(QSize(image_width, image_height));
    
        emit drowMiniature(imageReader.read());
    
    }
    

    mainwindow.cpp

    ThreadsMiniature *threadB = new ThreadsMiniature(this,imagePathListCopy.at(i));
                    connect(threadB, SIGNAL(ThreadsMiniature::drowMiniature(QImage)),this,SLOT(MainWindow::Miniature(QImage)));
                    threadB->start();
    
    void MainWindow::Miniature (QImage image) {
        qDebug()<<image<<"_+___+";
            item_one = new QStandardItem();
            item_one->setData(QVariant(QPixmap::fromImage(image)), Qt::DecorationRole);
            model->setItem(rowTableDisk, 2, item_one);
    }
    

    I receive:

    QObject::connect: No such signal QThread::ThreadsMiniature::drowMiniature(QImage)
    QObject::connect: (receiver name: 'MainWindow')
    QObject::connect: No such signal QThread::ThreadsMiniature::drowMiniature(QImage)
    QObject::connect: (receiver name: 'MainWindow')


  • Qt Champions 2017

    You have forgotten the Q_OBJECT macro.



  • @kshegunov said in QObject::connect: No such signal QThread::ThreadsMiniature::drowMiniature(QImage):

    Q_OBJECT

    Yes, I forgot Q_OBJECT. Thank you so much.
    Now Errors:

    threadsminiature.obj:-1: ошибка: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl ThreadsMiniature::metaObject(void)const " (?metaObject@ThreadsMiniature@@UEBAPEBUQMetaObject@@XZ)

    threadsminiature.obj:-1: ошибка: LNK2001: unresolved external symbol "public: virtual void * __cdecl ThreadsMiniature::qt_metacast(char const *)" (?qt_metacast@ThreadsMiniature@@UEAAPEAXPEBD@Z)

    threadsminiature.obj:-1: ошибка: LNK2001: unresolved external symbol "public: virtual int __cdecl ThreadsMiniature::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@ThreadsMiniature@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

    threadsminiature.obj:-1: ошибка: LNK2019: unresolved external symbol "public: void __cdecl ThreadsMiniature::drowMiniature(class QImage)" (?drowMiniature@ThreadsMiniature@@QEAAXVQImage@@@Z) referenced in function "public: virtual void __cdecl ThreadsMiniature::run(void)" (?run@ThreadsMiniature@@UEAAXXZ)

    debug\ObservationLog.exe:-1: ошибка: LNK1120: 4 unresolved externals



  • @kshegunov All right. Many thanks.


  • Lifetime Qt Champion

    Hi,

    You signal definition is wrong. See Qt's documentation about them. Basically, their return type is void and you don't implement them yourself.


Log in to reply