Spinn Code
Loading Please Wait
  • Home
  • My Profile

Share something

Explore Qt Development Topics

  • Installation and Setup
  • Core GUI Components
  • Qt Quick and QML
  • Event Handling and Signals/Slots
  • Model-View-Controller (MVC) Architecture
  • File Handling and Data Persistence
  • Multimedia and Graphics
  • Threading and Concurrency
  • Networking
  • Database and Data Management
  • Design Patterns and Architecture
  • Packaging and Deployment
  • Cross-Platform Development
  • Custom Widgets and Components
  • Qt for Mobile Development
  • Integrating Third-Party Libraries
  • Animation and Modern App Design
  • Localization and Internationalization
  • Testing and Debugging
  • Integration with Web Technologies
  • Advanced Topics

About Developer

Khamisi Kibet

Khamisi Kibet

Software Developer

I am a computer scientist, software developer, and YouTuber, as well as the developer of this website, spinncode.com. I create content to help others learn and grow in the field of software development.

If you enjoy my work, please consider supporting me on platforms like Patreon or subscribing to my YouTube channel. I am also open to job opportunities and collaborations in software development. Let's build something amazing together!

  • Email

    infor@spinncode.com
  • Location

    Nairobi, Kenya
cover picture
profile picture Khamisi Kibet

10 Months ago | 194 views

<div><div> <p>I'm working on creating a custom widget for Qt Designer in Python using PyQt or PySide. I want to expose an enum property in the Qt Designer property editor, so that users can select from a list of predefined options rather than typing in arbitrary values.</p> <p>In C++, it is possible to expose an enum to Qt Designer using Q_ENUMS and Q_PROPERTY, as described in this [Stack Overflow question](https://stackoverflow.com/questions/49172604/qt-custom-widget-plugin-q-property-with-enum).</p> <p>I want to achieve the same result in Python. Specifically, I want to:</p> <p>- Define an enum in Python that can be used as a property in my custom widget.<br>- Ensure that this enum is displayed as a dropdown list in the Qt Designer property editor.</p> <p><br>Here's an outline of what I have so far:</p> <pre class="language-python"><code>from qtpy.QtCore import Qt, QEasingCurve, QPropertyAnimation, QSize, Property, QPoint, QEnum from qtpy.QtWidgets import QCheckBox, QApplication, QLabel from enum import Enum class EasingCurveEnum(Enum): Option1 = 0 Option2 = 1 Option3 = 2 class QCustomCheckBox(QCheckBox): def __init__(self, parent=None): super().__init__(parent) self._easing_curve = EasingCurveEnum.Option1 # ... @Property(EasingCurveEnum, designable=True) def animationEasingCurve(self): return self._easing_curve @animationEasingCurve.setter def animationEasingCurve(self, curve): self._easing_curve = curve</code></pre> <p> </p> <p> </p> <p>How can I make the EasingCurveEnum property appear as a list of options in the Qt Designer property editor?</p> <p>**I've successfully registered my custom widget in Qt Designer, but the enum list property is not appearing.**</p> <p>Any guidance or examples would be greatly appreciated!</p> <p>Thanks in advance!</p> <p>**UPDATE:**</p> <p>Tried this, it didn't work:</p> <pre class="language-python"><code>@QEnum class EasingCurveEnum(Enum): .... </code></pre> <p>I also tried this, did not work either:</p> <pre class="language-python"><code>class EasingCurveEnum(Enum): Option1 = 0 Option2 = 1 Option3 = 2 class QCustomCheckBox(QCheckBox): def __init__(self, parent=None): super().__init__(parent) #tried..... QEnum(EasingCurveEnum) self._easing_curve = EasingCurveEnum.Option1 # ... @Property(EasingCurveEnum, designable=True) def animationEasingCurve(self): return self._easing_curve @animationEasingCurve.setter def animationEasingCurve(self, curve): self._easing_curve = curve</code></pre> </div></div>
blog

Qt Designer: Display a List of Enum Options in Custom Widget Properties Editor Using Python

<div><div> <p>I'm working on creating a custom widget for Qt Designer in Python using PyQt or PySide. I want to expose an enum property in the Qt Designer property editor, so that users can select from a list of predefined options rather than typing in arbitrary values.</p> <p>In C++, it is possible to expose an enum to Qt Designer using Q_ENUMS and Q_PROPERTY, as described in this [Stack Overflow question](https://stackoverflow.com/questions/49172604/qt-custom-widget-plugin-q-property-with-enum).</p> <p>I want to achieve the same result in Python. Specifically, I want to:</p> <p>- Define an enum in Python that can be used as a property in my custom widget.<br>- Ensure that this enum is displayed as a dropdown list in the Qt Designer property editor.</p> <p><br>Here's an outline of what I have so far:</p> <pre class="language-python"><code>from qtpy.QtCore import Qt, QEasingCurve, QPropertyAnimation, QSize, Property, QPoint, QEnum from qtpy.QtWidgets import QCheckBox, QApplication, QLabel from enum import Enum class EasingCurveEnum(Enum): Option1 = 0 Option2 = 1 Option3 = 2 class QCustomCheckBox(QCheckBox): def __init__(self, parent=None): super().__init__(parent) self._easing_curve = EasingCurveEnum.Option1 # ... @Property(EasingCurveEnum, designable=True) def animationEasingCurve(self): return self._easing_curve @animationEasingCurve.setter def animationEasingCurve(self, curve): self._easing_curve = curve</code></pre> <p> </p> <p> </p> <p>How can I make the EasingCurveEnum property appear as a list of options in the Qt Designer property editor?</p> <p>**I've successfully registered my custom widget in Qt Designer, but the enum list property is not appearing.**</p> <p>Any guidance or examples would be greatly appreciated!</p> <p>Thanks in advance!</p> <p>**UPDATE:**</p> <p>Tried this, it didn't work:</p> <pre class="language-python"><code>@QEnum class EasingCurveEnum(Enum): .... </code></pre> <p>I also tried this, did not work either:</p> <pre class="language-python"><code>class EasingCurveEnum(Enum): Option1 = 0 Option2 = 1 Option3 = 2 class QCustomCheckBox(QCheckBox): def __init__(self, parent=None): super().__init__(parent) #tried..... QEnum(EasingCurveEnum) self._easing_curve = EasingCurveEnum.Option1 # ... @Property(EasingCurveEnum, designable=True) def animationEasingCurve(self): return self._easing_curve @animationEasingCurve.setter def animationEasingCurve(self, curve): self._easing_curve = curve</code></pre> </div></div>

Images

More from Khamisi

Weather App UI Redesign
3 Years ago 655 views
Responsive And Animated Admin Dashboard | Python QT | QT Designer | PySide | PyQt | Modern GUI
3 Years ago 6830 views
Python Desktop App To Monitor All System Information | PYQT5/6 | PYSIDE2/6 | PSUTIL [Modern GUI/ UI]
3 Years ago 3591 views
Let's vote!
2 Years ago 228 views
PART #14:[MODERN UI] - [ GUI ] PROGRESS BARS Python Desktop App QTDesigner,Pyqt5,Pysid,PySide2extn
4 Years ago 704 views
Photography Design
5 Years ago 69 views
Spinn Code Team
About | Home
Contact: info@spinncode.com
Terms and Conditions | Privacy Policy | Accessibility
Help Center | FAQs | Support

© 2025 Spinn Company™. All rights reserved.
image