Why does designer automatically add dynamic properties?



  • Hi,

    I created a custom qtdesigner widget.

    It just looks normal in desinger,but It automatically adds dynamic properties When using this widget.

    It produces the following code

        _CAvatarItem->setProperty("avatarVisiable", QVariant(false));
        _CAvatarItem->setProperty("groupVisiable", QVariant(false));
        _CAvatarItem->setProperty("genderVisiable", QVariant(false));
        _CAvatarItem->setProperty("isGroupHolder", QVariant(false));
        _CAvatarItem->setProperty("nameIconVisiable", QVariant(false));
    

    I did not add these attributes,Why does this code appear?


  • Qt Champions 2016

    It looks kinda odd.
    Is that from the code generated in the setUI ?

    Have you tried to use it in a clean new project ?

    It seems to come from user code as "Visiable" seems misspelled for "Visible"

    Make sure the widget you promote do not have it.

    I have not seen such properties added when making Designer plugins.



  • @mrjj Thank you for your answer.

    I'm also very confused.

    This section of code generated in the setupUi.

    It's a totally new project,very clean.

    I added some protected functions,as follows:

        protected:
                void setAvatarVisiable(const bool);
                bool avatarVisiable()const;
    
                void setGroupVisiable(const bool);
                bool groupVisiable()const;
    
                void setGenderVisiable(const bool);
                bool genderVisiable()const;
    
                void setImportantContactFlag(const bool);
                bool isImportantContact()const;
    
                void setCustomContactFlag(const bool);
                bool isCustomContact()const;
    
                void setGroupHolder(const bool);
                bool isGroupHolder()const;
    
                void setNameIconVisiable(const bool);
                bool nameIconVisiable()const;
    
                void setJobIconVisiable(const bool);
                bool jobIconVisiable()const;
    
                void setLatestLabelVisiable(const bool);
                bool latestLabelVisiable()const;
    
                void setRemindVisiable(const bool);
                bool remindVisiable()const;
    

    but I didn't use macro Q_PROPERTY for these functions.They are just simple member functions.


  • Qt Champions 2016

    hi A.Michael

    I will try to add some protected member funcs into one of my designer plugins and see if I can replicate it.

    Currently I have no idea why they would become props.

    Its almost magical :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.