Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 328155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:28:07+00:00 2026-05-12T09:28:07+00:00

Pretty simple question. I’ve seen it mentioned in many places that using properties on

  • 0

Pretty simple question. I’ve seen it mentioned in many places that using properties on an old-style class shouldn’t work, but apparently Qt classes (through PyQt4) aren’t new-style and there are properties on a few of them in the code I’m working with (and as far as I know the code isn’t showing any sorts of problems)

I did run across a pyqtProperty function, but I can’t seem to find any documentation about it. Would it be a good alternative in this instance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:28:07+00:00Added an answer on May 12, 2026 at 9:28 am

    property works because QObject has a metaclass that takes care of them. Witness this small variation on @quark’s code…:

    from PyQt4.QtCore import QObject
    
    def makec(base):
      class X( base ):
          def __init__(self):
              self.__x = 10
          def get_x(self):
              print 'getting',
              return self.__x
          def set_x(self, x):
              print 'setting', x
              self.__x = x
          x = property(get_x, set_x)
    
      print 'made class of mcl', type(X), issubclass(type(X), type)
      return X
    
    class old: pass
    for base in (QObject, old):
      X = makec(base)
      x = X()
      print x.x # Should be 10
      x.x = 30
      print x.x # Should be 30
    

    running this emits:

    made class of mcl <type 'PyQt4.QtCore.pyqtWrapperType'> True
    getting 10
    setting 30
    getting 30
    made class of mcl <type 'classobj'> False
    getting 10
    30
    

    see the difference? In the class that’s really a legacy (old-type) class, the one made the second time, metaclass is classobj (which ISN’T a subclass of type) and properties don’t work right (assigning x.x bypasses the property, and after that getting x.x doesn’t see the property any more either). But in the first case, the Qt case, there’s a different metaclass, and it IS a subclass of type (so it’s not really correct to say the class “isn’t new-style”!), and things therefore DO work correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 230k
  • Answers 230k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think I've come to the conclusion that there is… May 13, 2026 at 2:06 am
  • Editorial Team
    Editorial Team added an answer var $myDiv = $('<div />'); This will create a div… May 13, 2026 at 2:06 am
  • Editorial Team
    Editorial Team added an answer Debugging an applet uses appletviewer, not a true browser. You… May 13, 2026 at 2:06 am

Related Questions

Pretty simple question, I'm writing an XML document and i'm not sure how to
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out
Pretty simple question. I've seen it mentioned in many places that using properties on
Pretty simple question, I know.
Pretty simple question, how can I transform a number (1, 2, 3, etc) into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.