Discussion:
[Qt-creator] How to add custom property type to the designer?
Jarvis
2018-03-23 11:41:37 UTC
Permalink
Hello£¬I want to add custom property type to the designer.


I'm trying to do that£º



struct TestType { int x; int y; }; Q_DECLARE_METATYPE(TestType) class ... { Q_OBJECT Q_PROPERTY(TestType Test READ Test WRITE SetTest) ... };
But the property do not appear in the designer.Property type can only be Qt's own?(and Q_ENUM¡¢Q_FLAGS)
Jaroslaw Kobus
2018-04-03 08:28:37 UTC
Permalink
Yes, QDesigner supports only types it knows. However, the list of known types is quite large.


Taking into account that uic needs to convert an xml based property values into the C++ code, it wouldn't be easily possible without any plugin architecture / extension system of uic.

________________________________
From: Qt-creator <qt-creator-bounces+jaroslaw.kobus=***@qt-project.org> on behalf of Jarvis <***@qq.com>
Sent: Friday, March 23, 2018 12:41:37 PM
To: qt-creator
Subject: [Qt-creator] How to add custom property type to the designer?

Hello£¬I want to add custom property type to the designer.

I'm trying to do that£º


struct TestType
{
int x;
int y;
};
Q_DECLARE_METATYPE(TestType)

class ...
{
Q_OBJECT
Q_PROPERTY(TestType Test
READ Test
WRITE SetTest)
...
};


But the property do not appear in the designer.

Property type can only be Qt's own?(and Q_ENUM¡¢Q_FLAGS)
Jaroslaw Kobus
2018-04-03 09:16:08 UTC
Permalink
No, uic is not extensible.

________________________________
From: Jarvis <***@qq.com>
Sent: Tuesday, April 3, 2018 10:34:33 AM
To: Jaroslaw Kobus
Subject: »ØžŽ£º [Qt-creator] How to add custom property type to the designer?

OK£¬thanks. QT is there an example of uic extension(plugin)?

------------------ Ô­ÊŒÓÊŒþ ------------------
·¢ŒþÈË: "Jaroslaw Kobus"<***@qt.io>;
·¢ËÍʱŒä: 2018Äê4ÔÂ3ÈÕ(ÐÇÆÚ¶þ) ÏÂÎç4:28
ÊÕŒþÈË: "Jarvis"<***@qq.com>;"qt-creator"<qt-***@qt-project.org>;
Ö÷Ìâ: Re: [Qt-creator] How to add custom property type to the designer?


Yes, QDesigner supports only types it knows. However, the list of known types is quite large.


Taking into account that uic needs to convert an xml based property values into the C++ code, it wouldn't be easily possible without any plugin architecture / extension system of uic.

________________________________
From: Qt-creator <qt-creator-bounces+jaroslaw.kobus=***@qt-project.org> on behalf of Jarvis <***@qq.com>
Sent: Friday, March 23, 2018 12:41:37 PM
To: qt-creator
Subject: [Qt-creator] How to add custom property type to the designer?

Hello£¬I want to add custom property type to the designer.

I'm trying to do that£º


struct TestType
{
int x;
int y;
};
Q_DECLARE_METATYPE(TestType)

class ...
{
Q_OBJECT
Q_PROPERTY(TestType Test
READ Test
WRITE SetTest)
...
};


But the property do not appear in the designer.

Property type can only be Qt's own?(and Q_ENUM¡¢Q_FLAGS)
Loading...