[Solved]custom widget does not show up in Qt Creator
-
Dear Qt Community,
I created a custom widget plugin following the example at http://doc.qt.nokia.com/4.7-snapshot/designer-customwidgetplugin.html. After "make install" in the build-desktop directory, I opened the Qt Designer and saw the widget. However, when I opened the Qt Creator I could not see the widget and in Tools->Form Editor->About Qt Designer Plugins... the .dylib was not loaded. Subsequent open of Qt Designer could not see the widget either. What should I do? Thanks in advance.
My OS Mac OS X v10.6.7
Qt SDK v4.7.3I intend to use the widget in Qt Creator for desktop app.
-
The your version of Creator may be looking for plugins in a different spot than Designer. You probably need to move the lib into the plugins directory of the Creator app bundle. Also note that the plugin may crash Creator if you have not also compiled Creator.
-
Hi babazaroni,
Thanks for the response. I noticed that I have two Qt Designer executables. They are located at:
~/QtSDK/Designer
~/QtSDK/Desktop/Qt/473/gcc/bin/DesignerIf I open the second one, I can see my widget. Not the first one.
I manually copied my .dylib to ~/QtSDK/Qt Creator.app/Contents/PlugIns/designer/, the Qt Creator crashes at start up, exactly as you advised.
So, I need to get the Qt Creator source code to compile in my box. Could you forward me the link for the source code and important steps for the compilation? Besides the Creator, do I need to compile any other component if I want to use the custom widgets in the SDK?
Thanks again.
-
The Creator source is here:
http://qt.nokia.com/downloads/qt-creator-source-package
Since you already have Creator installed, double click on the top-level .pro file and rebuild.
I don't believe you need to do anything else, but get your dylib in the proper spot. I'm a newbie on all this, but I went through exactly what you are doing a week ago and got my custom widget working. I'm not interested in getting Creator design mode going since windows have to remain inside the main app window. Designer and a large display are what I need. Now if someone can tell me how to get debugger helper on mac working, I'd be pretty happy. (see my earlier post)
-
Hi babazaroni,
Following your advice, I downloaded the source code and built the new Qt Creator. Then I manually copied the new Qt Create to ~/QtSDK. I can see my custom widget in the new Creator. I created a project, which only put one of my widget (HLine) into the main window. When compile, I got link error:
Undefined symbols:
"HLine::HLine(QWidget*)", referenced from:
Ui_MainWindow::setupUi(QMainWindow*) in mainwindow.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [t.app/Contents/MacOS/t] Error 1
make: Leaving directory `/Users/stu/qt/t-build-desktop'
The process "/usr/bin/make" exited with code 2.
Error while building project t (target: Desktop)
When executing build step 'Make'what I missed?
Thanks.
-
Here is the problem: Your application (not only Qt Designer) needs to have the widget. The designer plugin only lets Qt Designer know that your application should be able to use the widget, but it in itself doesn't provide the widget to the application (I hope this makes it more clear for you - the standard widgets that you usually use in Qt Creator are all in the QtGui library)
You have basically two options:- You can add BOTH the header and the sources of your widget to your project
- Or you can make a new library that includes all your widgets (I would recommend this if you need to use them across multiple applications.
-
Hi loladiro,
I compiled the .dylib and installed it in ~/QtSDK/Desktop/Qt/473/gcc/plugin/designer directory. So I can use my widget in the Creator's ui form. Since ~/QtSDK/Desktop/Qt/473/gcc/include and ~/QtSDK/Desktop/Qt/473/gcc/lib are included and linked in the g++ compiler, I copied the header to the include directory and the .dylib to the lib directory. But the "ld: symbol(s) not found" error is still there.
Should I put the .dylib in different directory?
Thanks for the help.