SIP with PyQt5 and "A More Complex C++ Example"

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

SIP with PyQt5 and "A More Complex C++ Example"

bitmap.kid
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.

Thanks you.
Sincerely


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIP with PyQt5 and "A More Complex C++ Example"

Phil Thompson-5
On 23 Mar 2019, at 11:46 am, bitmap kid <[hidden email]> 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
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIP with PyQt5 and "A More Complex C++ Example"

bitmap.kid
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 <[hidden email]> a écrit :
On 23 Mar 2019, at 11:46 am, bitmap kid <[hidden email]> 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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIP with PyQt5 and "A More Complex C++ Example"

bitmap.kid
Maybe, the complete history of my commands will help you:



[th@mecanic ~/sip] ls
hello.cpp  hello.h  hello.sip  main.cpp
[th@mecanic ~/sip] sip -t WS_X11 -I /usr/share/sip/PyQt5 -c . hello.sip
[th@mecanic ~/sip]  /usr/bin/g++  -DDEBUG -DHOST -DQT_CORE_LIB -DQT_GUI_LIB -Dserver_EXPORTS -I. -I../ -Iserver_autogen/include -I../. -I/usr/include/python3.7m  -isystem /usr/include/qt -isystem /usr/include/qt/QtCore -isystem /usr/lib/qt/mkspecs/linux-g++ -g -fPIC   -Wall -pedantic -fPIC -std=gnu++17 -MD -I /usr/include/qt/QtWidgets/ -I /usr/include/qt/QtGui/ -c *.cpp
./siphellocmodule.cpp: Dans la fonction « PyObject* func_setDefault(PyObject*, PyObject*) »:
./siphellocmodule.cpp:438:13: error: « setDefault » n'a pas été déclaré dans cette portée
             setDefault(*a0);
             ^~~~~~~~~~
./siphellocmodule.cpp:438:13: note: alternatives suggérées: « func_setDefault »
             setDefault(*a0);
             ^~~~~~~~~~
             func_setDefault



Le sam. 23 mars 2019 à 13:09, bitmap kid <[hidden email]> a écrit :
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 <[hidden email]> a écrit :
On 23 Mar 2019, at 11:46 am, bitmap kid <[hidden email]> 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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIP with PyQt5 and "A More Complex C++ Example"

Phil Thompson-5
In reply to this post by bitmap.kid
The example is missing...

%ModuleCode
#include <hello.h>
%End

Thanks,
Phil

> On 23 Mar 2019, at 12:09 pm, bitmap kid <[hidden email]> 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 <[hidden email]> a écrit :
> On 23 Mar 2019, at 11:46 am, bitmap kid <[hidden email]> 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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: SIP with PyQt5 and "A More Complex C++ Example"

bitmap.kid
Problem solved ! Everything works fine now !

Un très grand merci !

bitmap.kid

Le sam. 23 mars 2019 à 13:29, Phil Thompson <[hidden email]> a écrit :
The example is missing...

%ModuleCode
#include <hello.h>
%End

Thanks,
Phil

> On 23 Mar 2019, at 12:09 pm, bitmap kid <[hidden email]> 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 <[hidden email]> a écrit :
> On 23 Mar 2019, at 11:46 am, bitmap kid <[hidden email]> 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


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt