Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How can I call the const method variant on a Qt object from Python?

How can I call the const method variant on a Qt object from Python?

Scheduled Pinned Locked Moved Unsolved Qt for Python
qt for pythonpyside
3 Posts 2 Posters 291 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kellyjp
    wrote on last edited by
    #1

    Hi,

    I'm trying to use a Qt API from PySide6 that has two overloaded methods with the same C++ signature except for the const specifier.
    In C++ the compiler picks the correct variant of the method based on the const-ness of the object.
    But Python doesn't have const objects so I am trying to figure out is there another way to call the const variant of the method as the non-const method doesn't do what I need and Python seems to always call this variant.

    The specific Qt class I am having the issue with is QDBusArgument.
    It has "void beginMapEntry()" and "void beginMapEntry() const" signatures in C++.
    The non-const variant is used for marshalling objects into a QDBusArgument object.
    The const variant is used for de-marshalling objects out of a QDBusArgument (what I need).

    Note that the QDBusArgument class has many method signatures which differ only in their const-ness.

    Any insights would be appreciated!

    Regards James

    1 Reply Last reply
    0
    • F Offline
      F Offline
      friedemannkleint
      wrote on last edited by
      #2

      This is not possible, currently. The function would have to be added under a different name.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kellyjp
        wrote on last edited by
        #3

        Thanks for clarifying. I suspected this would be the case but I thought it was worth asking the question.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved