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. Problem with getting icons for applications
QtWS25 Last Chance

Problem with getting icons for applications

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 2.8k 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #1

    Hi! I want to get icons for all installed applications (using registry) on Windows. The problem is:

    QObject::connect: Cannot queue arguments of type 'QList<QIcon>'
    (Make sure 'QList<QIcon>' is registered using qRegisterMetaType().)
    

    How to fix it? Thanks in advance.

    jsulmJ 1 Reply Last reply
    0
    • Cobra91151C Cobra91151

      Hi! I want to get icons for all installed applications (using registry) on Windows. The problem is:

      QObject::connect: Cannot queue arguments of type 'QList<QIcon>'
      (Make sure 'QList<QIcon>' is registered using qRegisterMetaType().)
      

      How to fix it? Thanks in advance.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Cobra91151 What are you trying to connect to what?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by
        #3

        @jsulm

        I'm connecting data from Worker class

        QThread *programsThread = new QThread();
        Worker *programsWorker = new Worker();
        programsWorker->moveToThread(programsThread);
        connect(programsWorker, &Worker::appData, this, &Test::setAppData);
        
        QList<QIcon> programIcons;
        emit appData(programIcons, displayNames, displayVersions, publishers, installLocation, uninstallLocations);
        

        and in Test class setting data in QTreeWidgetItem (QTreeWidget)

        void setAppData(QList<QIcon> icons, QStringList names, QStringList versions, QStringList publishers, QString installLocation, QStringList uninstallLocations);
        
        jsulmJ 1 Reply Last reply
        0
        • Cobra91151C Cobra91151

          @jsulm

          I'm connecting data from Worker class

          QThread *programsThread = new QThread();
          Worker *programsWorker = new Worker();
          programsWorker->moveToThread(programsThread);
          connect(programsWorker, &Worker::appData, this, &Test::setAppData);
          
          QList<QIcon> programIcons;
          emit appData(programIcons, displayNames, displayVersions, publishers, installLocation, uninstallLocations);
          

          and in Test class setting data in QTreeWidgetItem (QTreeWidget)

          void setAppData(QList<QIcon> icons, QStringList names, QStringList versions, QStringList publishers, QString installLocation, QStringList uninstallLocations);
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Cobra91151 The error message actually tells you how to fix: "Make sure 'QList<QIcon>' is registered using qRegisterMetaType()".
          See here for details: http://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType.
          It should be enough to do it for QUcon, QList should already be supported.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          3
          • Cobra91151C Offline
            Cobra91151C Offline
            Cobra91151
            wrote on last edited by
            #5

            @jsulm
            So I should use this function like: qRegisterMetaType<QIcon>("QIcon");

            But where to initialize (call) it (in Worker or in Test class)? Thanks.

            jsulmJ 1 Reply Last reply
            0
            • Cobra91151C Cobra91151

              @jsulm
              So I should use this function like: qRegisterMetaType<QIcon>("QIcon");

              But where to initialize (call) it (in Worker or in Test class)? Thanks.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Cobra91151 where you do the connection

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              Cobra91151C 1 Reply Last reply
              2
              • jsulmJ jsulm

                @Cobra91151 where you do the connection

                Cobra91151C Offline
                Cobra91151C Offline
                Cobra91151
                wrote on last edited by
                #7

                @jsulm

                void Test::appProgramsThread()
                {
                    qRegisterMetaType<QIcon>("QIcon");
                
                    try {
                        QThread *programsThread = new QThread();
                        Worker *programsWorker = new Worker();
                        programsWorker->moveToThread(programsThread);
                        connect(programsThread, &QThread::started, programsWorker, &Test::programsData);
                        connect(programsWorker, &Worker::appData, this, &Test::setAppData);
                        connect(programsWorker, &Worker::noAppsData, this, &Test::allApplicationsEmptyData);
                        connect(programsWorker, &Worker::appDataReady, this, &Test::setAppLogData);
                        connect(programsWorker, &Worker::finished, programsThread, &QThread::quit);
                        connect(programsWorker, &Worker::finished, programsWorker, &Worker::deleteLater);
                        connect(programsThread, &QThread::finished, programsThread, &QThread::deleteLater);
                        programsThread->start();
                    } catch (...) {
                        QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("An error has occurred with detecting programs!"));
                    }
                }
                

                Also I have tried to call it in setAppData function but it doesn't work. The same issue: QObject::connect: Cannot queue arguments of type 'QList<QIcon>' (Make sure 'QList<QIcon>' is registered using qRegisterMetaType().).

                jsulmJ 1 Reply Last reply
                0
                • Cobra91151C Cobra91151

                  @jsulm

                  void Test::appProgramsThread()
                  {
                      qRegisterMetaType<QIcon>("QIcon");
                  
                      try {
                          QThread *programsThread = new QThread();
                          Worker *programsWorker = new Worker();
                          programsWorker->moveToThread(programsThread);
                          connect(programsThread, &QThread::started, programsWorker, &Test::programsData);
                          connect(programsWorker, &Worker::appData, this, &Test::setAppData);
                          connect(programsWorker, &Worker::noAppsData, this, &Test::allApplicationsEmptyData);
                          connect(programsWorker, &Worker::appDataReady, this, &Test::setAppLogData);
                          connect(programsWorker, &Worker::finished, programsThread, &QThread::quit);
                          connect(programsWorker, &Worker::finished, programsWorker, &Worker::deleteLater);
                          connect(programsThread, &QThread::finished, programsThread, &QThread::deleteLater);
                          programsThread->start();
                      } catch (...) {
                          QMessageBox::critical(this, QObject::tr("Error"), QObject::tr("An error has occurred with detecting programs!"));
                      }
                  }
                  

                  Also I have tried to call it in setAppData function but it doesn't work. The same issue: QObject::connect: Cannot queue arguments of type 'QList<QIcon>' (Make sure 'QList<QIcon>' is registered using qRegisterMetaType().).

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Cobra91151 Sorry, actually you should use http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE

                  Q_DECLARE_METATYPE(QIcon)
                  

                  But I'm wondering why it is not working out of the box for QIcon as it is Qts own class.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  Cobra91151C 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Cobra91151 Sorry, actually you should use http://doc.qt.io/qt-5/qmetatype.html#Q_DECLARE_METATYPE

                    Q_DECLARE_METATYPE(QIcon)
                    

                    But I'm wondering why it is not working out of the box for QIcon as it is Qts own class.

                    Cobra91151C Offline
                    Cobra91151C Offline
                    Cobra91151
                    wrote on last edited by
                    #9

                    @jsulm

                    I have declare it in a header file (Test.h) where I make a connection

                    class Test : public QWidget
                    {
                        Q_OBJECT
                    
                     public:
                        Test();  
                    
                     signals:
                    
                     public slots:
                           void setAppData(QList<QIcon> icons, QStringList names, QStringList versions, QStringList publishers, QString installLocation, QStringList uninstallLocations);
                    
                     private:
                    };
                    
                    Q_DECLARE_METATYPE(QIcon)
                    

                    The same issue is still present.

                    1 Reply Last reply
                    0
                    • Cobra91151C Offline
                      Cobra91151C Offline
                      Cobra91151
                      wrote on last edited by Cobra91151
                      #10

                      When I use in Test class

                      class Test : public QWidget
                      {
                          Q_OBJECT
                          Q_DECLARE_METATYPE(QIcon)
                      ....
                      

                      I get errors:

                      error: C3412: 'QMetaTypeId<QIcon>': cannot specialize template in current scope
                      

                      I'm using Qt 5.7.1 (Win 10).
                      So, where to initialize it? Thanks.

                      Cobra91151C 1 Reply Last reply
                      0
                      • Cobra91151C Cobra91151

                        When I use in Test class

                        class Test : public QWidget
                        {
                            Q_OBJECT
                            Q_DECLARE_METATYPE(QIcon)
                        ....
                        

                        I get errors:

                        error: C3412: 'QMetaTypeId<QIcon>': cannot specialize template in current scope
                        

                        I'm using Qt 5.7.1 (Win 10).
                        So, where to initialize it? Thanks.

                        Cobra91151C Offline
                        Cobra91151C Offline
                        Cobra91151
                        wrote on last edited by Cobra91151
                        #11

                        @Cobra91151

                        Problem solved:

                        I have changed code to: qRegisterMetaType<QList<QIcon>>("QList<QIcon>"); and it works now.

                        1 Reply Last reply
                        0

                        • Login

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