MacOS deploying styles
-
Hi, I've compiled the qtstyleplugins under qt5.0.0 osx. It works only without deploying libraries into the app bundle (macdeployqt).
If I try to run the app:
@Class NotificationReceiver is implemented in both /app-bundle-path.../QtWidgets and /qt-abs-path/QtWidgets. One of the two will be used. Which is undefined.
Abort trap@otool -L test.app/Contents/PlugIns/libqplastiquestyle.dylib
- All qt-libraries are located under @executable_path/../Frameworks - no absolute path...
Is it possible to deploy qtstyleplugins inside the app-bundle?
Thanks for help.
Martin -
Hi,
Check that your executable and other dependencies also have their path updated (even Qt libraries to be sure)
-
The problem is probably not with qtstyleplugins.
My program:
@int main(int argc, char *argv[]) {
QApplication::setStyle("xxx");
QApplication app(argc, argv);@The style "xxx" doesn't exist, this application runs in default osx style - without deploying. After deploying it shows the error above...
otool -L for every library (including executable) in the bundle returns correct paths (@executable_path) -
Did you check what QStyleFactory::keys() returns ?
-
No custom style used:
@#include "mainwindow.h"
#include <QApplication>
#include <qstylefactory.h>
#include <qdebug.h>int main(int argc, char *argv[])
{
qDebug() << QStyleFactory::keys();QApplication a(argc, argv); MainWindow w; w.show(); return a.exec();
}@
("Windows", "Fusion", "Macintosh")
objc[2880]: Class NotificationReceiver is implemented in both /Users/martin.dusek/cpp/teststyle-build-5_0_0_x64-Release/teststyle.app/Contents/MacOS/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /usr/local/qt-5.0.0/x64/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x102712a10) is not the object's thread (0x102719830).
Cannot move to target thread (0x102712a10)On Mac OS X, you might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
Failed to load platform plugin "cocoa". Available platforms are:
cocoa
minimal
minimalAbort trap
Without deploying:
(“Windows”, “Fusion”, “Macintosh”)- no crash
Deployed + commented out this line:
@//qDebug() << QStyleFactory::keys();@- no crash
It looks like that any touch to QStyle in OSX = crash :(
-
The error message you get tells you that not all your libs/exec are linked against the same Qt which means that at least one of your dependencies has not the proper paths set (have you also the plugins in the bundle ? Did you "otool" them ?)
-
All dependencies are prefixed with @executable_path. It is really strange...
-
For all Qt libraries ?
-
yes.
This is OK:
@QApplication a(argc, argv);
qDebug() << QStyleFactory::keys();@This crashes:
@qDebug() << QStyleFactory::keys();
QApplication a(argc, argv);@ -
@QApplication a(argc, argv);
QApplication::setStyle("plastique");@Works!
There is a hint in qt-docs - QApplication::setStyle
To ensure that the application's style is set correctly, it is best to call this function before the QApplication constructor, if possible.This is impossible on mac...
-
Time to use
@#ifdef Q_OS_MACX@unless it's a mac only app