Setting up PythonQt in Qt Creator on Arch Linux
-
wrote on 16 Apr 2014, 11:27 last edited by
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 tovtable 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 tovtable 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 tovtable 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 tovtable 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 tovtable 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 tovtable 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 tovtable 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 += coreQT -= gui
TARGET = PythonQtTest
CONFIG += console
CONFIG -= app_bundleINCLUDEPATH += /usr/include/python2.7
INCLUDEPATH += /usr/include/PythonQtTEMPLATE = 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();
}
@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.
-
wrote on 17 Apr 2014, 18:01 last edited by
Hi,
undefined reference error refer to class included in QtWidget module.
Try to modify your code in order to link Qt5Gui e Qt5Widgets -
wrote on 18 Apr 2014, 15:41 last edited by
-
wrote on 22 Apr 2014, 21:44 last edited by
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. -
wrote on 23 Apr 2014, 08:35 last edited by
Hi,
PyQt5 is built for Qt5 but requires Python 3.x
-
wrote on 28 Apr 2014, 09:27 last edited by
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. -
wrote on 28 Apr 2014, 09:35 last edited by
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
1/7