Qt Designer Custom Widget on OS X
-
I've been banging my head over this for a week now. I'm new to Qt so I'm sure I've missed something.
I'm designing my app and would like to use a custom widget since the stock ones don't display the way I want and I'd like to see the widget in designer. I'd rather not use promotion to make this work. I've tried a downloaded custom widget and the analog clock custom widget. Both compile and install just fine. Because of how the Qt Creator is done for Mac, the new plugin must be copied to the package contents of Qt Creator.app (inside the Plugins/designer folder). But when ever I do this and reopen designer, it crashes. A snippet of the crash report is:
@
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff99246866 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff8f0f235c pthread_kill + 92
2 libsystem_c.dylib 0x00007fff962eab1a abort + 125
3 QtCore 0x000000011682b019 qt_message_fatal(QtMsgType, QMessageLogContext const&, QString const&) + 9
4 QtCore 0x000000011682b651 QMessageLogger::fatal(char const*, ...) const + 161
5 QtWidgets 0x0000000115d7fdfc QWidgetPrivate::QWidgetPrivate(int) + 604
6 QtWidgets 0x0000000115d80bde QWidget::QWidget(QWidget*, QFlagsQt::WindowType) + 46
7 libcustomwidgetplugin.dylib 0x000000010289df27 AnalogClock::AnalogClock(QWidget*) + 23
8 libcustomwidgetplugin.dylib 0x000000010289e5d2 non-virtual thunk to AnalogClockPlugin::createWidget(QWidget*) + 34
9 QtDesigner 0x000000010c610d3e qdesigner_internal::WidgetFactory::createCustomWidget(QString const&, QWidget*, bool*) const + 190
10 QtDesigner 0x000000010c61145b qdesigner_internal::WidgetFactory::createWidget(QString const&, QWidget*) const + 91
@Unfortunately this crash report means nothing to me. Hopefully I've included the relevant portion. (also found it funny that the demo files of the analog clock widget plugin was missing the json file that was clearly linked in the project)
I'm using the DMG package of Qt. As far as I can tell both Qt and the custom widgets are both compiled with Clang 64 (but I honestly can't tell for Qt). I have XCode installed.
Considering the instruction in the documentation seem relatively simple, I'm assuming there is something specific that must be done on the OS X platform.
If I need to compile a version of Qt for my system, I'd love a proper step by step set of instructions. I found one set of instructions and after compiling (qt-everywhere-opensource-src-5.2.1.tar.gz) I only ended up with Qt Designer not the whole Qt Creator package. I also tried to build the project file from qt-creator-opensource-src-3.0.1.tar.gz using the DMG version of Qt and got build errors.
-
Hi and welcome to devnet,
Can you start Qt Creator from the command line ? You might get additional information before the crash
-
Thanks for the reply.
Using the command
open /Volumes/Macintosh\ HD\ 2/Developer/test/mainwindow.ui
it immediately crashes with the same crash report from Apple. There is no info that terminal is giving me.Plugin's target path is set to $$[QT_INSTALL_PLUGINS]/designer so after make install, it copies the plugin to /Applications/Qt/5.2.1/clang_64/plugins/designer so I have to move it to /Applications/Qt/Qt\ Creator.app/Contents/PlugIns/designer
-
Sorry, I meant call the executable from the command line, don't use open
-
Sorry, miss understood you.
Using the command
/Applications/Qt/Qt\ Creator.app/Contents/MacOS/Qt\ Creator
I have to open the test project and open the ui file. After it crashes the terminal has:
@Info: creating stash file /Volumes/Macintosh HD 2/Developer/build-test-Desktop_Qt_5_2_1_clang_64bit-Debug/.qmake.stash
objc[50667]: Class NotificationReceiver is implemented in both /Applications/Qt/Qt Creator.app/Contents/Frameworks/QtWidgets.framework/Versions/5/QtWidgets and /Applications/Qt/5.2.1/clang_64/lib/QtWidgets.framework/Versions/5/QtWidgets. One of the two will be used. Which one is undefined.
QWidget: Must construct a QApplication before a QWidget
Abort trap: 6@I like seeing the better logging as to what is going wrong, but I still don't know what is actually going wrong.
-
It means your plugin is using your own built Qt and Qt Creator it's bundled Qt so technically you have two choices:
Build Qt Creator with the same Qt you are using for your plugin
use install_name_tool to point your plugin to the Qt libs of Qt Creator (not test though)
-
Thanks for all the help. I got it working after building Qt Creator from the Git repository.
Here's what I did based on http://qt-project.org/wiki/Building-Qt-Creator-from-Git
Install the DMG of Qt into /Library/Qt
Add /Library/Qt/5.2.1/clang_64/bin directory to the PATH variable
Make a folder /Applications/Qt
Clone the Git repository into /Applications/Qt/qt-creator (first tried on a separate drive but this failed in the make process)
In terminal in the /Applications/Qt folder run 'qmake -r qt-creator/qtcreator.pro'
Then run 'make -j3'
Once this is done it makes a functional Qt Creator.app inside the bin folder (/Applicaitons/Qt/bin)
I had to manually add a kit but this was fairly minor.Rebuilding the designer plugin in release mode and run 'make install' placed the plugin in the correct folder. After reopening Qt Creator I could see the widget in the list of designer widgets. The widget is placed into /Library/Qt/5.2.1/clang_64/plugins/designer
I'm not sure about debug mode (if it's needed or not and what to do with it from there).
-
Next question would be the header files (and maybe the cpp files). How would I put them into the "core" so that I don't have to include the physical files in each project that uses them.
In other words, is it possible to integrate the plugin enough that #include <customWidget> could be used instead of #include "customWidget.h" and copying the files to a library folder in each project.
-
When using #include <QWidget> you have a header file called QWidget that points to the actual qwidget.h
For the rest, you can have a look at "this":https://qt-project.org/doc/qtcreator-3.0/adding-plugins.html it will be quicker