Python Forum
Converting c++ class to python class
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Converting c++ class to python class
#11
Ok, another c++ clas that I 'm tryin to convert to python:

HEADER file:
class OptionGroup : public QWidget
{
Q_OBJECT
Q_PROPERTY(int currentSelection READ currentSelection WRITE setCurrentSelection USER true)
SOURCE file:
OptionGroup::OptionGroup(QWidget *parent) :QWidget(parent), currentSelection_(-1)
{
}
What do you think of this, is it correct?
class OptionGroup(QtGui.QWidget) :
    def __init__(self, parent):
        super(OptionGroup, self).__init__(parent)
        self.currentSelection_ = -1
        self.currentSelection = pyqtProperty(int, self.getCurrentSelection, self.setCurrentSelection)
Reply
#12
I found the solution!
Changed:
currentSelection = pyqtProperty(int, currentSelection, setCurrentSelection)
...to:

currentSelection = pyqtProperty(int, currentSelection, setCurrentSelection, user = True)
Reply
#13
Thanks for sharing!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python inner classes inheritance from parent class Abedin 8 616 Apr-23-2025, 05:56 AM
Last Post: Gribouillis
  Accessing method attributes of python class Abedin 6 883 Apr-14-2025, 07:02 AM
Last Post: buran
  Python class members based on a type value voidtrance 7 1,251 Apr-11-2025, 10:10 PM
Last Post: deanhystad
  Create a new subclass in a Python extension based on an existing class voidtrance 6 1,421 Mar-25-2025, 06:37 PM
Last Post: voidtrance
  printing/out put issue with class arabuamir 3 993 Aug-25-2024, 09:29 AM
Last Post: arabuamir
  Class test : good way to split methods into several files paul18fr 5 3,781 Jul-17-2024, 11:12 AM
Last Post: felixandrea
  [split] Class and methods ebn852_pan 15 3,344 May-23-2024, 11:57 PM
Last Post: ebn852_pan
  [SOLVED] [listbox] Feed it with dict passed to class? Winfried 3 1,318 May-13-2024, 05:57 AM
Last Post: Larz60+
  Class and methods Saida2024 2 1,122 May-13-2024, 04:04 AM
Last Post: deanhystad
  How does this code create a class? Pedroski55 6 2,062 Apr-21-2024, 06:15 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020