How to create a component
Hello!
I want to create a gui component to be used in Qt programming (just a subclass of QTabWidget, btw). At first thought I imagined that I just had to create an independent Qt Designer Form Class, but as soon as I saw the interface I noticed that doing so I'ld have something slighty different from what I want...
As far as I know, if just create the .ui, the .cpp and .hpp files, I'l have to add all the 3 files to my project and then start using them. But rather I'ld like to make it more like traditional gui Qt components, even including my component in Qt Designer (more precisely, in the Designer embbed in Qt Creator).
So how do I do this?
Instead of creating the files and including them in the project, create them in such a way I can add my component to QtDesigner and use them in my project just by adding #include <xxx> in the appropriate place.
I hope I was clear enough :)
Thanks,
Momergil
Re: How to create a component
See http://qt-project.org/doc/qt-4.8/des...getplugin.html It covers all your questions. After creating a library you can simply use #include <###> or you integrate the new class in a local Qt repository.
Re: How to create a component
If you class does not change the resize behavior of the base class or any such fundamental change then it is often easier to just use the "promote widget" functionality in designer.
Basically you add a QTabWidget and the promote it to you class. The generated code will then create an instance of your class instead of QTabWidget.
Cheers,
_
1 Attachment(s)
Re: How to create a component
Thanks for the link, Lykurg. I managed to do it all fine till the " Q_EXPORT_PLUGIN2" macro; the tutorial doesn't say where to put this macro (and all parts of the code where I inserted, it always returned with the same failure:
Attachment 9389
)
Could you please tell me how to solve this?
Thanks,
Momergil
---
Thanks anda_skoa. I tested this solution as well, but it seems to bring the limitation that I'ld have to create a new class for each new app I develop, and that wasn't my intention :)
Re: How to create a component
The tutorial shows you exactly where the macro goes. Did you look at the example code?
As for your error message, we have no idea what your code actually looks like. My guess is you have not #included something you should have.
Re: How to create a component
Quote:
Originally Posted by
Momergil
Thanks anda_skoa. I tested this solution as well, but it seems to bring the limitation that I'ld have to create a new class for each new app I develop, and that wasn't my intention :)
Not if you put it into a library.
Cheers,
_