Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QObject::connect: No such signal QThread::ThreadsMiniature::drowMiniature(QImage)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 755 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    haifisch
    wrote on last edited by haifisch
    #1

    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')

    kshegunovK 1 Reply Last reply
    0
    • H haifisch

      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')

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      You have forgotten the Q_OBJECT macro.

      Read and abide by the Qt Code of Conduct

      H 2 Replies Last reply
      3
      • kshegunovK kshegunov

        You have forgotten the Q_OBJECT macro.

        H Offline
        H Offline
        haifisch
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0
        • kshegunovK kshegunov

          You have forgotten the Q_OBJECT macro.

          H Offline
          H Offline
          haifisch
          wrote on last edited by
          #4

          @kshegunov All right. Many thanks.

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved