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
  class and runtime akbarza 4 282 Mar-16-2024, 01:32 PM
Last Post: deanhystad
  Operation result class SirDonkey 6 422 Feb-25-2024, 10:53 AM
Last Post: Gribouillis
  The function of double underscore back and front in a class function name? Pedroski55 9 562 Feb-19-2024, 03:51 PM
Last Post: deanhystad
  super() and order of running method in class inheritance akbarza 7 594 Feb-04-2024, 09:35 AM
Last Post: Gribouillis
  Class test : good way to split methods into several files paul18fr 4 403 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  Good class design - with a Snake game as an example bear 1 1,713 Jan-24-2024, 08:36 AM
Last Post: annakenna
  question about __repr__ in a class akbarza 4 529 Jan-12-2024, 11:22 AM
Last Post: DeaD_EyE
  error in class: TypeError: 'str' object is not callable akbarza 2 445 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  super() in class akbarza 1 402 Dec-19-2023, 12:55 PM
Last Post: menator01
  error occuring in definition a class akbarza 3 636 Nov-26-2023, 09:28 AM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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