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. read QString type Q_PROPERTY in axserver from js always return empty
Forum Updated to NodeBB v4.3 + New Features

read QString type Q_PROPERTY in axserver from js always return empty

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 195 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.
  • Y Offline
    Y Offline
    youcl
    wrote on last edited by youcl
    #1
    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.

    1 Reply Last reply
    0
    • Y Offline
      Y Offline
      youcl
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      1

      • Login

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