[SOLVED] std::string and Q_PROPERTY()
I am unable to get std::string properties for my custom widget to appear in QtDesigner.
Below is an example of the code i'm running that isn't working. Any suggestions?
class CustomCheckBox : public QCheckBox
// this property does NOT appear in QtDesigner
Q_PROPERTY(std::string name READ getName WRITE setName)
public: CustomCheckBox(QWidget* parent = nullptr); virtual ~CustomCheckBox(); void setName(const std::string& x); std::string getName() const; private: std::string name;
CustomCheckBox::CustomCheckBox(QWidget* parent) : QCheckBox(parent)
// doesn't work
// doesn't work qRegisterMetaType<std::string>("std::string");
std::string is a template specification (some kind of typedef).
I think that Q_PROPERTY doesn't workfor templates (check on the documentation).
Anyway IMHO it's better to use QString as property.
I...should have known that. Thank you. Using QString will probably be what I do now.