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 | 206 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

YouTube Video Shortifier
10 Months ago 161 views
Weather App UI Redesign
3 Years ago 669 views
PART #6:[MODERN UI] - [ GUI ] Python Desktop App Drag/Move Window QTDesigner,Pyqt5,Py
4 Years ago 1984 views
Sci-Fi/ Encription Key Generator
5 Years ago 455 views
Photography Design
5 Years ago 77 views
Animated popup notification and side menu widgets | Free Source Code | Python PyQT PySide QT
3 Years ago 1580 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