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
Forum Updated to NodeBB v4.3 + New Features

Problem with getting icons for applications

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 2 Posters 2.9k 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.
  • C Offline
    C Offline
    Cobra91151
    wrote on 29 May 2017, 10:44 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.

    J 1 Reply Last reply 29 May 2017, 10:49
    0
    • C Cobra91151
      29 May 2017, 10:44

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 29 May 2017, 10:49 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
      • C Offline
        C Offline
        Cobra91151
        wrote on 29 May 2017, 10:55 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);
        
        J 1 Reply Last reply 29 May 2017, 11:02
        0
        • C Cobra91151
          29 May 2017, 10:55

          @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);
          
          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 29 May 2017, 11:02 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
          • C Offline
            C Offline
            Cobra91151
            wrote on 29 May 2017, 11:19 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.

            J 1 Reply Last reply 29 May 2017, 11:29
            0
            • C Cobra91151
              29 May 2017, 11:19

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

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 29 May 2017, 11:29 last edited by
              #6

              @Cobra91151 where you do the connection

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

              C 1 Reply Last reply 29 May 2017, 11:50
              2
              • J jsulm
                29 May 2017, 11:29

                @Cobra91151 where you do the connection

                C Offline
                C Offline
                Cobra91151
                wrote on 29 May 2017, 11:50 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().).

                J 1 Reply Last reply 29 May 2017, 11:57
                0
                • C Cobra91151
                  29 May 2017, 11:50

                  @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().).

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 29 May 2017, 11:57 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

                  C 1 Reply Last reply 29 May 2017, 12:09
                  0
                  • J jsulm
                    29 May 2017, 11:57

                    @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.

                    C Offline
                    C Offline
                    Cobra91151
                    wrote on 29 May 2017, 12:09 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
                    • C Offline
                      C Offline
                      Cobra91151
                      wrote on 29 May 2017, 14:50 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.

                      C 1 Reply Last reply 29 May 2017, 17:28
                      0
                      • C Cobra91151
                        29 May 2017, 14:50

                        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.

                        C Offline
                        C Offline
                        Cobra91151
                        wrote on 29 May 2017, 17:28 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

                        5/11

                        29 May 2017, 11:19

                        • Login

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