0

To add a custom widget to Qt designer simply follow the steps:

  1. In Qt designer create a new widget File->New->Widget.
  2. Add your UI etc for this widget and save it->->MyWidget.ui
  3. Create a class "MyWidgetHandler" to handle this widget in a MyWidgetHandler.h & cpp
  4. In your MainWindow/Dialog wherever you want to display this widget add a "Widget" from the "Containers" section of the designer.

    enter image description here

  5. Now right-click the "Widget" container you just added and click "Promote to..."

  6. 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.
  7. Next enter the full class name i.e with namespaces eg: "blah::MyWidgetHandler"
  8. 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"
  9. Now click "Promote" and save your MainWindow.ui
  10. The Property Editor should now show your custom class type eg: blah::MyWidgetHandler. and the properties from the base class you selected.
  11. 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

+ Recent posts