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 5971093
In Process

The Archive Base Latest Questions

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

anyone knows if there exists a method for passing pyQt objects to c++ code?

  • 0

anyone knows if there exists a method for passing pyQt objects to c++ code?

I’ll explain better; say i have this c++ code

    void QtGuiPDLVisitor::set_layout(QLayout* _layout){
       layout = _layout;
    }

where QtGuiPDLVisitor is a c++ class exported in python using SWIG, so in python i want to do something like this

    layout = QtGui.QGridLayout()
    visitor = QtGuiPDLVisitor()
    visitor.set_layout(layout)

is it possible? The python interpreter says no :(… is there any workaround, like a way of passing pointers or any other hack?

EDIT:

Traceback (most recent call last):
  File "/home/picci/workspace/gestface/pypelab/src/pypelab/ui/pipeworkarea.py", line 53, in create_new_computation
    subWindowWidget.setComputation(idx.data())
  File "/home/picci/workspace/gestface/pypelab/src/pypelab/ui/pypeWidgets.py", line 44, in setComputation
    self.widBuilder.buildUi(self)
  File "/home/picci/workspace/gestface/pypelab/src/pypelab/ui/pypeWidgets.py", line 63, in buildUi
    pdlVisitor.set_layout(criteria_area_layout)
  File "/home/picci/workspace/gestface/pipeit/wrap/python/dist/Debug/pipeit.py", line 736, in set_layout
    def set_layout(self, *args) -> "void" : return _pipeit.QtGuiPDLVisitor_set_layout(self, *args)
TypeError: in method 'QtGuiPDLVisitor_set_layout', argument 2 of type 'QLayout *'

This is the error from python. I already know that this error is due to the fact that Qt4 is wrapper in python using SIP, while i’m using SWIG to wrap, but i think that there must be a way to access directly to the pointer of the Qlayout object and pass it to C++ code from python.

  • 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-22T20:28:08+00:00Added an answer on May 22, 2026 at 8:28 pm

    Ok i actually find a way to do that. I used

    visitor.set_layout_address(sip.unwrapinstance(layout))
    

    from python, and than in c++

    void QtGuiPDLVisitor::set_layout_address(long _layout_address){
        layout = reinterpret_cast<QLayout*>(_layout_address);
    }
    

    and worked!

    here sip doc for more about sip.unwrapinstance()

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

Sidebar

Related Questions

Is anyone working on or know if there exists a SQL 2k8 Dialect for
Anyone knows if there is an easy or known way to write a deep
Are there any replacements for NUnitAsp that anyone knows of for testing ASP.NET pages?
Does anyone know whether there's a way to mock Entity Data Provider so Unit
Does anyone know if there is a c# Console app, similar to the Python
Does anyone know why there is no respond_to block for generated edit actions? Every
Does anyone know if there is a good equivalent to Java's Set collection in
Does anyone know if there's an add-in that does autocomplete for queries on SQL
Does anyone know if there is an API to get the current monitor state
Does anyone know if there is an implementation of javax.jms.QueueConnectionFactory for WebSphere MQ and

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.