[PyQt] SIP with PyQt5 and "A More Complex C++ Example"

bitmap kid bitmap.kid at gmail.com
Sat Mar 23 12:43:13 GMT 2019


Problem solved ! Everything works fine now !

Un très grand merci !

bitmap.kid

Le sam. 23 mars 2019 à 13:29, Phil Thompson <phil at riverbankcomputing.com> a
écrit :

> The example is missing...
>
> %ModuleCode
> #include <hello.h>
> %End
>
> Thanks,
> Phil
>
> > On 23 Mar 2019, at 12:09 pm, bitmap kid <bitmap.kid at gmail.com> wrote:
> >
> > Oh obviously !
> >
> > hello.h ================================================
> > #ifndef HELLO_H
> > #define HELLO_H
> > #include <QLabel>
> > #include <QWidget>
> > #include <QString>
> >
> > class Hello : public QLabel {
> >     // This is needed by the Qt Meta-Object Compiler.
> >     Q_OBJECT
> >
> > public:
> >     Hello(QWidget *parent = 0);
> >
> > private:
> >     // Prevent instances from being copied.
> >     Hello(const Hello &);
> >     Hello &operator=(const Hello &);
> > };
> >
> > #if !defined(Q_OS_WIN)
> > void setDefault(const QString &def);
> > #endif
> > #endif // HELLO_H
> >
> > hello.cpp ================================================
> > #include "hello.h"
> >
> > Hello::Hello(QWidget *parent): QLabel(parent) {}
> > Hello::Hello(const Hello &other) { (void) other; }
> > Hello &Hello::operator=(const Hello &other) { (void) other; return
> *this; }
> >
> > #if !defined(Q_OS_WIN)
> > void setDefault(const QString &def) { (void) def; }
> > #endif
> >
> > hello.sip ================================================
> > // Define the SIP wrapper to the hello library.
> >
> > %Module hello
> >
> > %Import QtGui/QtGuimod.sip
> > %Import QtWidgets/QtWidgetsmod.sip
> >
> > %If (Qt_5_0_0 -)
> >
> > class Hello : public QLabel {
> >
> > %TypeHeaderCode
> > #include <hello.h>
> > %End
> >
> > public:
> >     Hello(QWidget *parent /TransferThis/ = 0);
> >
> > private:
> >     Hello(const Hello &);
> > };
> >
> > %If (!WS_WIN)
> > void setDefault(const QString &def);
> > %End
> >
> > %End
> >
> >
> >
> >
> >
> > Le sam. 23 mars 2019 à 13:05, Phil Thompson <phil at riverbankcomputing.com>
> a écrit :
> > On 23 Mar 2019, at 11:46 am, bitmap kid <bitmap.kid at gmail.com> wrote:
> > >
> > > Bonjour,
> > >
> > > I'm trying to make the example "A More Complex C++ Example" given in
> the documentation. But I'm having trouble with the setDefault function.
> > >
> > > Once the sources generated with the sip command, when I compile, the
> compiler says:
> > >
> > > ./siphellocmodule.cpp:438:13: error: "setDefault" was not declared in
> this scope.
> > >               setDefault (* a0);
> > >
> > > Indeed, the siphellocmodule.cpp file refers to the setDefault function
> but does not include hello.h
> > >
> > > Do you have an idea of where the problem is?
> > >
> > > Please, note :
> > > I am using PyQt5 5.12.1 and SIP 4.19.5.
> > > My project consists of hello.h, hello.cpp and hello.sip files
> > > My sip command is "sip -t WS_X11 -I /usr/share/sip/PyQt5 -c.hello.sip"
> > > It generates the following files:
> > >
> > >     sipAPIhello.h
> > >     siphelloHello.cpp
> > >     siphellocmodule.cpp
> > >
> > > And commenting the setDefault function build the project correctly.
> >
> > Difficult to say without seeing your hello.h, hello.cpp and hello.sip.
> >
> > Phil
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190323/941b7e56/attachment.html>


More information about the PyQt mailing list