Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    3
    5
    490
    Loading More Posts
    • 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
      haifisch last edited by 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')

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @haifisch last edited by

        You have forgotten the Q_OBJECT macro.

        Read and abide by the Qt Code of Conduct

        H 2 Replies Last reply Reply Quote 3
        • H
          haifisch @kshegunov last edited by

          @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 Reply Quote 0
          • H
            haifisch @kshegunov last edited by

            @kshegunov All right. Many thanks.

            1 Reply Last reply Reply Quote 1
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 3
              • First post
                Last post