Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QSortFilterProxyModel* as signal argument is undefined in QML
Forum Updated to NodeBB v4.3 + New Features

QSortFilterProxyModel* as signal argument is undefined in QML

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 342 Views 1 Watching
  • 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi,
    I have the following class to be used as model for a QML TableView

    class ProcessProxyModel : public QSortFilterProxyModel {
    Q_OBJECT
    ...
    signals:
    void procModelReady(const ProcessProxyModel* procmodel);
    
    private:
    ProcessProxyModel* m_procModel;
    }
    

    The class is registered as:

        qmlRegisterUncreatableType<ProcessProxyModel>("com.dirac", 1, 0, "ProcessProxyModel", "Type is not allowed to be instantiated");
    
    

    When the model is ready, I emit a signal as follows:

    emit procModelReady(m_procModel);
    

    In QML however, the object passed is not recognized and reported as undefined.

    On the other hand, if I explicitly query for the model via:

    Q_INVOKABLE ProcessProxyModel* getProcProxy() const {
       return m_procModel;
    }
    

    it works.

    To summarize, in QML:

    Connections {
            target: sysmon
    
            function onProcModelReady(model)    {
                console.debug(model)                                 // <--- prints undefined
                console.debug(sysmon.getProcProxy()) //<-- Works correctly
            }
    

    Why is the signal argument's type not recognized?

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

      Hi,

      Don't you have any runtime message about an unknown type being used in your signal ?

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

      DiracsbracketD 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Don't you have any runtime message about an unknown type being used in your signal ?

        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by
        #3

        @SGaist
        Thanks, but no such message appears.

        DiracsbracketD 1 Reply Last reply
        0
        • DiracsbracketD Diracsbracket

          @SGaist
          Thanks, but no such message appears.

          DiracsbracketD Offline
          DiracsbracketD Offline
          Diracsbracket
          wrote on last edited by
          #4

          The problem was due to the const specifier.

          signals:
          void procModelReady(const ProcessProxyModel* procmodel);
          

          Changing it to:

          signals:
          void procModelReady(ProcessProxyModel* procmodel);
          

          works.

          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