472,351 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

example needed: sip + Qt

Hi,

can someone provide me with a running example for subclassing QWidget (or
something similarly simple) in C++ and then creating SIP (4.x+) bindings
for in for Python (2.3+)?

I am looking for something I can start of with and work my way towards more
complicated stuff (with Qt).

The QLabel example in the SIP reference manual yields syntax errors for me.
Same with:
http://www.pegasus.rutgers.edu/~elfl...ss_example.tgz

thanks,
Uwe
Jul 18 '05 #1
8 2793
On Fri, 2005-01-28 at 13:30 +0100, Uwe Mayer wrote:
Hi,

can someone provide me with a running example for subclassing QWidget (or
something similarly simple) in C++ and then creating SIP (4.x+) bindings
for in for Python (2.3+)?


Out of curiosity, would this be for an extension module used in an
embedded Python interpreter, or for plain extension module for use with
a standalone interpreter?

I'm afraid I can't help you with your specific problem, though I'll be
interested to hear if anybody here does know.

If you don't have any luck here, try the PyQt/PyKDE list (and search its
archives first).

--
Craig Ringer

Jul 18 '05 #2
> Hi,

can someone provide me with a running example for subclassing QWidget (or
something similarly simple) in C++ and then creating SIP (4.x+) bindings
for in for Python (2.3+)?

I am looking for something I can start of with and work my way towards
more
complicated stuff (with Qt).

The QLabel example in the SIP reference manual yields syntax errors for
me.


What syntax errors? If there is a documentation bug then I'll fix it.

Phil

Jul 18 '05 #3
On Friday 28 January 2005 14:47 pm, Phil Thompson wrote:
The QLabel example in the SIP reference manual yields syntax errors for
me.


What syntax errors? If there is a documentation bug then I'll fix it.


I'll come to that a little later, that happened in the simple c++ word
example.

I am currently fiddling around with the QLabel example. I copied the example
and tried it out. First problem was that the generated makefile does not
attempt to compile the original hello.cpp sources.

So I wrote a configure script and a Makefile.am for that.
It was not clear to me what type of archive or object was needed, so I first
tried creating a normal object file, then libtool archives and then normal
archives. It turned out I needed a normal archive an the library search path
has to be extended to include the current directory (-L.), i.e. where the
libhello.a lies.
My only way of doing so was edditing the Makefile generated by configure.py.
Is there a way of telling that to configure.py?

So now the hello.cpp example compiles. I fire up python:
import hello

Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./hello.so: undefined symbol: _ZTV5Hello

$ c++filt _ZTV5Hello
vtable for Hello

The compilation did not give any warnings or error messages. Any ideas?

Thanks
Uwe
--
It would seem that evil retreats when forcibly confronted.
-- Yarnek of Excalbia, "The Savage Curtain", stardate 5906.5

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUAQfq6JeU60gD77wDfAQJoiQf/UIH66LxzzrxqwUNEIOFruIuMmICoWvqZ
S/INqzmLaOzhcpoj/lN1i0YjroGT1AWR08LtIuew4JCQX0IQejgZ0nefzMDjgDs4
BLcL1Aofj6CQm5tVdEglZvCZ9XXE3VKuXgQJtU7xVuhW2JEHsM LuGREdgpphxGl0
I67HRD//+/m7F66a3/CEfurycvljjNenCkn3mCMKBHnXGNXX2TeE8dtYPVGPcN9n
8SmVsAOcR3g/SsgEJSSYxi2pZY47gn95AEqAZhB7XSJNBp/xbFEk5Ha1XInvfsBw
uuePMDwzhOPsZNauJxpnoYWKPg+gcGukqAFi4zoXRA6ZvU9xgO 3gXg==
=FFcq
-----END PGP SIGNATURE-----

Jul 18 '05 #4
On Friday 28 January 2005 14:24 pm, Craig Ringer wrote:
Out of curiosity, would this be for an extension module used in an
embedded Python interpreter, or for plain extension module for use with
a standalone interpreter?


I am writing an application program using Python and PyQt:
https://savannah.nongnu.org/projects/lmc/

At one point I am using a QListView but need my items to be sorted
numerically. There is no function to set the sort-criterea and the solution
to this is subclassing QListViewItem and overwrite the comparison functions.
However, doing so in Python was awfully slow for a greater number of items,
so I want to rewrite this in C++ and wrap it back to python.

Ciao
Uwe
--
Kilroe hic erat!

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iQEVAwUAQfq7GOU60gD77wDfAQJgtAf/QsZbbCuNO3vcrf8TOMv1Vcti7w/iMw/W
fBJkcIokbX6HrnU4oVWnHc8Zz1DAXsxMSNPp2bC65TfPNgGzep EJHX/LvHhvHTOR
BN38BmmXhZysCPj+hE8a0sXs/4mCOZVBfjJ9Wn5hRsymMSZ0/R+oc2KfPLZSM0Ga
eri+rokfW+e4JECM5YVOc9pXM6rWY7aNC+NEx1m05Z3t+28CHw H+Kfw+qQfNDXyI
va84m6kNe3alCSXgGwRK5q6639BjBjW36xjdfzxl+sCACcIBB6 xeJZ5Hhgc61hWK
6N6ZIBomzM1QgC3sAUK24cjbh0BMpOJweBKD18tFG2prUKSb3t SyRA==
=55t6
-----END PGP SIGNATURE-----

Jul 18 '05 #5
Friday 28 January 2005 23:18 pm Uwe Mayer wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./hello.so: undefined symbol: _ZTV5Hello

$ c++filt _ZTV5Hello
vtable for Hello

The compilation did not give any warnings or error messages. Any ideas?


$ ldd -d hello.so
libqt-mt.so.3 => /usr/lib/libqt-mt.so.3 (0x40057000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4190c000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4154e000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x41173000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40743000)
libm.so.6 => /lib/tls/libm.so.6 (0x4114f000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x407fd000)
libc.so.6 => /lib/tls/libc.so.6 (0x41019000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x418d8000)
libaudio.so.2 => /usr/lib/libaudio.so.2 (0x40807000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x4191c000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x4081c000)
libz.so.1 => /usr/lib/libz.so.1 (0x41856000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x41749000)
libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x40842000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x41734000)
libXft.so.2 => /usr/lib/libXft.so.2 (0x416e1000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x42487000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x42583000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x4256a000)
libdl.so.2 => /lib/tls/libdl.so.2 (0x41184000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x40847000)
undefined symbol: _ZTV5Hello (./hello.so)
undefined symbol: _ZNK5Hello9classNameEv (./hello.so)
undefined symbol: _ZN5Hello7qt_castEPKc (./hello.so)
undefined symbol: _ZN5Hello9qt_invokeEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello7qt_emitEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello11qt_propertyEiiP8QVariant (./hello.so)
undefined symbol: _ZTI5Hello (./hello.so)
undefined symbol: _Py_NoneStruct (./hello.so)
undefined symbol: PyCObject_Type (./hello.so)

Uwe
Jul 18 '05 #6
Friday 28 January 2005 23:39 pm Uwe Mayer wrote:
Friday 28 January 2005 23:18 pm Uwe Mayer wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./hello.so: undefined symbol: _ZTV5Hello

$ c++filt _ZTV5Hello
vtable for Hello

The compilation did not give any warnings or error messages. Any ideas?
$ ldd -d hello.so
libqt-mt.so.3 => /usr/lib/libqt-mt.so.3 (0x40057000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4190c000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4154e000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x41173000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40743000)
libm.so.6 => /lib/tls/libm.so.6 (0x4114f000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x407fd000)
libc.so.6 => /lib/tls/libc.so.6 (0x41019000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x418d8000)
libaudio.so.2 => /usr/lib/libaudio.so.2 (0x40807000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x4191c000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x4081c000)
libz.so.1 => /usr/lib/libz.so.1 (0x41856000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x41749000)
libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x40842000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x41734000)
libXft.so.2 => /usr/lib/libXft.so.2 (0x416e1000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x42487000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x42583000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x4256a000)
libdl.so.2 => /lib/tls/libdl.so.2 (0x41184000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x40847000)
undefined symbol: _ZTV5Hello (./hello.so)
undefined symbol: _ZNK5Hello9classNameEv (./hello.so)
undefined symbol: _ZN5Hello7qt_castEPKc (./hello.so)
undefined symbol: _ZN5Hello9qt_invokeEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello7qt_emitEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello11qt_propertyEiiP8QVariant (./hello.so)
undefined symbol: _ZTI5Hello (./hello.so)

undefined symbol: _Py_NoneStruct (./hello.so)
undefined symbol: PyCObject_Type (./hello.so)


Those last two can be removed if you link against libpython2.3.so and by
appending -lpython2.3 to the libs in the Makefile.

Uwe
Jul 18 '05 #7
So have you created the library you are trying to wrap? The documentation is
describing how to wrap a library and describes a fictional library as the
basis for the example.

Phil

On Friday 28 January 2005 11:02 pm, Uwe Mayer wrote:
Friday 28 January 2005 23:39 pm Uwe Mayer wrote:
Friday 28 January 2005 23:18 pm Uwe Mayer wrote:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: ./hello.so: undefined symbol: _ZTV5Hello

$ c++filt _ZTV5Hello
vtable for Hello

The compilation did not give any warnings or error messages. Any ideas?


$ ldd -d hello.so
libqt-mt.so.3 => /usr/lib/libqt-mt.so.3 (0x40057000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4190c000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4154e000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x41173000)
libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40743000)
libm.so.6 => /lib/tls/libm.so.6 (0x4114f000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x407fd000)
libc.so.6 => /lib/tls/libc.so.6 (0x41019000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x418d8000)
libaudio.so.2 => /usr/lib/libaudio.so.2 (0x40807000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x4191c000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x4081c000)
libz.so.1 => /usr/lib/libz.so.1 (0x41856000)
libXrender.so.1 => /usr/lib/libXrender.so.1 (0x41749000)
libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x40842000)
libXcursor.so.1 => /usr/lib/libXcursor.so.1 (0x41734000)
libXft.so.2 => /usr/lib/libXft.so.2 (0x416e1000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x42487000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x42583000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x4256a000)
libdl.so.2 => /lib/tls/libdl.so.2 (0x41184000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)
libexpat.so.1 => /usr/lib/libexpat.so.1 (0x40847000)
undefined symbol: _ZTV5Hello (./hello.so)
undefined symbol: _ZNK5Hello9classNameEv (./hello.so)
undefined symbol: _ZN5Hello7qt_castEPKc (./hello.so)
undefined symbol: _ZN5Hello9qt_invokeEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello7qt_emitEiP8QUObject (./hello.so)
undefined symbol: _ZN5Hello11qt_propertyEiiP8QVariant (./hello.so)
undefined symbol: _ZTI5Hello (./hello.so)

undefined symbol: _Py_NoneStruct (./hello.so)
undefined symbol: PyCObject_Type (./hello.so)


Those last two can be removed if you link against libpython2.3.so and by
appending -lpython2.3 to the libs in the Makefile.

Uwe

Jul 18 '05 #8
Saturday 29 January 2005 00:23 am Phil Thompson wrote:
So have you created the library you are trying to wrap? The documentation
is describing how to wrap a library and describes a fictional library as
the basis for the example.


No, the extracts from before are from the code example of the fictional
library with no further implementation.

By now I also found the problem: the poor python programmer did not care to
create the makefile (for building hello.cpp and hello.h) with qmake and
thus there were no moc files and that stupid programmer (me) could not link
against them.

It compiles and loads in python now.
Thanks
Uwe
Jul 18 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ville Vainio | last post by:
Just posting this for the sake of google: Like everyone else, I figured it's time to start using the 'logging' module. I typically want to...
1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way...
23
by: Alberto | last post by:
An OUTSTANDING example of a rebuttal. Worth a glance. Rather long, OBVIOUSLY feel fee to dismiss it entirely if not interested. But this habit...
12
by: Xah Lee | last post by:
Python Doc Problem Example Quote from: http://docs.python.org/lib/module-os.path.html ---------- split( path) Split the pathname path into a...
20
by: Xah Lee | last post by:
Sort a List Xah Lee, 200510 In this page, we show how to sort a list in Python & Perl and also discuss some math of sort. To sort a list in...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for...
13
by: KV | last post by:
I'm new to OO Design, and I'm fixing to start writing my very first C# program. Given the complexity of OO programming, I would like to run...
12
by: emma_middlebrook | last post by:
Hi Say you had N threads doing some jobs (not from a shared queue or anything like that, they each know how to do their own set of jobs in a...
25
by: meltedown | last post by:
This is supposed ot be an example: http://www.ajaxtutorial.net/index.php/2006/11/30/simple-ajax-using-prototype-part-2/ It says : This...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.