Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

read QString type Q_PROPERTY in axserver from js always return empty



  • class testDll : public QObject , public QAxBindable
    {
        Q_OBJECT
    
        Q_CLASSINFO("ClassID", "{}")
        Q_CLASSINFO("InterfaceID", "{}")
        Q_CLASSINFO("EventsID", "{}")
    
        Q_PROPERTY(QString name MEMBER m_name READ getName WRITE setName)
        Q_PROPERTY(int number MEMBER m_number READ getNumber WRITE setNumber)
    
    public:
        testDll(QObject *parent = 0);
        QString getName() const;
        int getNumber() const;
    
    public slots:
        void setName(QString v);
        void setNumber(int v);
    
    signals:
        void nameChanged(QString v);
    
    private:
        QString m_name;
        int m_number;
    };
    

    when using the axserver, it's ok to read the int Q_PROPERTY value in IE with js like :

            var dll = document.getElementById("testDll");
            var num1 = dll.number;
            console.log(num1);
            var num2 = testDll.number;
            console.log(num2);
    

    but when reading the QString Q_PROPERTY in the same way, it always return empty. But it's ok to get the QString with QString res = container->dynamicCall("name").toString(); in a qt axcontainer.

    I am new to activex with qt. Can anyone help? And is there any thorough tutorial or books about developing activex/com with qt? Thanks in advance.



  • I finally solved this. It's actually kind stupid: name cannnot be used as Q_PROPERTY name. After I change the property name, it works.



  • I finally solved this. It's actually kind stupid: name cannnot be used as Q_PROPERTY name. After I change the property name, it works.


Log in to reply