Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Setting up PythonQt in Qt Creator on Arch Linux
Forum Updated to NodeBB v4.3 + New Features

Setting up PythonQt in Qt Creator on Arch Linux

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 2 Posters 4.3k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MazeChaZer
    wrote on last edited by
    #1

    Hello everyone,

    I'm struggeling setting up the PythonQt library in Qt Creator.
    So far, I installed pythonqt from the AUR and added the library to my .pro file, but the build fails with the following error:

    @[...]
    g++ -Wl,-O1,--sort-common,--as-needed,-z,relro -o PythonQtTest main.o -lPythonQt -lQt5Core -lpthread
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWizard' Makefile:182: recipe for target 'PythonQtTest' failed /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWizardPage'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWheelEvent' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWidgetAction'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWhatsThis' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QVector4D'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWidget' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWindowsStyle'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QVector2D' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWorkspace'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QVector3D' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QValidator'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWhatsThisClickedEvent' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to vtable for PythonQtWrapper_QWidgetItem'
    /usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/../../../../lib/libPythonQt.so: undefined reference to `vtable for PythonQtWrapper_QWindowStateChangeEvent'
    [...]@

    This is my .pro file:

    @
    QT += core

    QT -= gui

    TARGET = PythonQtTest
    CONFIG += console
    CONFIG -= app_bundle

    INCLUDEPATH += /usr/include/python2.7
    INCLUDEPATH += /usr/include/PythonQt

    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS += PythonQt/PythonQt.h

    unix|win32: LIBS += -lPythonQt
    @

    And my main.cpp

    @
    #include <QCoreApplication>
    #include <PythonQt.h>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);

    PythonQt::init();
    
    PythonQtObjectPtr pythonContext = PythonQt::self()->getMainModule();
    pythonContext.evalScript("print 'Hello Python!';");
    
    return a.exec&#40;&#41;;
    

    }
    @

    Am I missing a certain include or library file? I already searched a lot on the Internet but I could not find a similar example.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      undefined reference error refer to class included in QtWidget module.
      Try to modify your code in order to link Qt5Gui e Qt5Widgets

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MazeChaZer
        wrote on last edited by
        #3

        Hi, thanks for the quick reply.

        I changed my .pro file the following way:
        I removed

        @QT -= gui@

        and added

        @QT += widgets
        QT += gui@

        In main.cpp I added

        @#include <QtGui>
        #include <QtWidgets>@

        But there are still the same errors as before... :(

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MazeChaZer
          wrote on last edited by
          #4

          Ok it turned out that I tried to use a Qt 4.8 version of PythonQt with Qt 5.2.
          It also seems that unfortunately there aren't any builds for Qt 5 yet. Meh.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mcosta
            wrote on last edited by
            #5

            Hi,

            PyQt5 is built for Qt5 but requires Python 3.x

            Once your problem is solved don't forget to:

            • Mark the thread as SOLVED using the Topic Tool menu
            • Vote up the answer(s) that helped you to solve the issue

            You can embed images using (http://imgur.com/) or (http://postimage.org/)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              MazeChaZer
              wrote on last edited by
              #6

              Thanks for the tip, but PyQt rather looks like a binding you would use to write your whole application in Python. I am going to write my application in C++ and wanted to make it Scriptable using PythonQt.
              Anyway, I'm looking at the Qt Script module again and I think I'll stick to this as it seems to provide the featues that I need.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mcosta
                wrote on last edited by
                #7

                Ok,

                if you want make an application Scriptable, the best (and the only Qt made) solution is to use QtScript module.

                As you stated PyQt task is to allow you to write the whole application in Python

                Once your problem is solved don't forget to:

                • Mark the thread as SOLVED using the Topic Tool menu
                • Vote up the answer(s) that helped you to solve the issue

                You can embed images using (http://imgur.com/) or (http://postimage.org/)

                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