0
To add a custom widget to Qt designer simply follow the steps:
- In Qt designer create a new widget File->New->Widget.
- Add your UI etc for this widget and save it->->MyWidget.ui
- Create a class "MyWidgetHandler" to handle this widget in a MyWidgetHandler.h & cpp
In your MainWindow/Dialog wherever you want to display this widget add a "Widget" from the "Containers" section of the designer.
Now right-click the "Widget" container you just added and click "Promote to..."
- This should open a dialog. You can select here the base class to inherit properties in your case QComboBox or just select the QWidget class.
- Next enter the full class name i.e with namespaces eg: "blah::MyWidgetHandler"
- In the Header file section simply add the path to the header file for this class. This should be a resolvable path. Eg: "UI/MyWidgetHandler.h" or "C:/UI/MyWidgetHandler.h"
- Now click "Promote" and save your MainWindow.ui
- The Property Editor should now show your custom class type eg: blah::MyWidgetHandler. and the properties from the base class you selected.
- Don't forget to setup the UI in your handler class and include header in the Mainwindow handler.
'QT' 카테고리의 다른 글
커스텀 위젯 만들기 노트 (0) | 2019.03.17 |
---|---|
Qt 동적 라이브러리 만들기 및 사용하기 (0) | 2019.03.16 |
커스텀 위젯 만들기 예제 (0) | 2019.03.10 |
Qtime 시간측정 예제 (0) | 2019.03.10 |
큐티 정적빌드 (0) | 2019.03.07 |