Custom Widget Problem
-
I've created a (container) custom widget using QT Creator -> New File or Project -> Other -> Qt Custom Designer Widget. After building, I copy the .so file (I'm using Ubuntu) to /usr/lib/qt4/plugins/designer and the plugin header file to both /usr/include and usr/include/qt4. Everything goes perfectly in designer...I can find my widget in the widgets panel and add it to my form. But when I try to build I get this error:
collect2: ld returned 1 exit status
The Compile output shows this:
mainwindow.cpp.text._ZN13Ui_MainWindow7setupUiEP11QMainWindow[Ui_MainWindow::setupUi(QMainWindow*)]+0x1382): undefined reference to `RDF_TempProbe_Widget::RDF_TempProbe_Widget(QWidget*)'
RDF_TempProbe_Widget is my custom widget. I've seen many threads discussing this problem but thus far have not been able to resolve it. Any ideas?
Thanks,
Rich -
you need to add yourcustomwidget.cpp to you project's file
@
HEADERS += yourcustomwidget.h
SOURCES += yourcustomwidget.cpp
@or
@
LIBS += yourcustomwidget.so # this is not a plugin!
@ -
Thanks for the input Robot Herder! Adding my widget's header and source files to the project did indeed work, but shouldn't Qt handle everything once I've successfully built the plugin and the widget? It seems like it should work just like any stock widget and I should be able to just plop it onto my form and everything is taken care of. That's the way it's worked in other environments I've used (primarily Delphi).
Thanks,
Rich -
In fact, that plugin isn't used in the build process. It's used by the designer only which assistant you to generate the .ui file. and in most cases, you doesn't need to create a plugin.
-
But if I want to see it in Designer so I can place it where I want it, I need a plugin, right? And it seems like I should be able to set it's properties in Designer just like I would any other widget.
Thanks for your tutoring...I really appreciate it!
Rich
-
[quote author="rdfrahm" date="1335837483"]But if I want to see it in Designer so I can place it where I want it, I need a plugin, right? And it seems like I should be able to set it's properties in Designer just like I would any other widget.
Rich[/quote]Yes, you are right. If you use this control frequently, create a plugin will give you much benefit.
;-)
But you can do nearly the same thing even without a plugin by Promoting Widgets and Dynamic Properties.
http://qt-project.org/doc/qt-4.8/designer-using-custom-widgets.html
http://qt-project.org/doc/qt-4.8/designer-widget-mode.html -
Thanks Robot Herder...I'll do (more) reading. I really appreciate your help!
Rich