PDA

View Full Version : How to re-use a customwidgets.dll I build ?



tonnot
15th March 2011, 10:37
I have my customwidgetplugin.dll (it has 3 custom widgets).
Ok, at designer I use one of them at 'myproject'. All runs fine.
I made a simple modification for one of this customwidget, recompile my plugindll and I hope I dont need to recompile 'myproject' ? However I must to do it. (because if not I dont see the changes)
What have I to do?

I leave the dll at the same folder of the myproject.exe
Thanks

high_flyer
15th March 2011, 10:58
However I must to do it.
You don't need to recompile, only to link again.


What have I to do?
To achieve what?

wysota
15th March 2011, 11:09
You don't need to recompile, only to link again.
My guess is he has to recompile because his widgets are probably added as source files directly to the project instead of being linked as a library. Unfortunately tonnot is one of those people who are not willing to devote time to understand things before they start using them. And I would gladly like to leave this question unanswered so that he has to do some research and finally understand some things instead of opening yet another thread in the newbie section all about the same thing.

tonnot
15th March 2011, 11:15
I have a litte confusion with the dll that contains my customwidgets.
When I use a customwidget, I open designer and drop Mywidget onto the form.
I have to include the files .h and .cpp by hand (sincerely I dont understand why ....)
At this moment if I build myprog, how is used mywidget, statically ?
And to use the dll directly, Have I to use Qpluginloader?
Thanks

wysota
15th March 2011, 11:19
I have to include the files .h and .cpp by hand (sincerely I dont understand why ....)
Exactly what I meant...

Tonnot, please... learn at least the basics of programming and using libraries.

tonnot
15th March 2011, 11:30
Wysota, when I say :

I have to include the files .h and .cpp by hand (sincerely I dont understand why ....)
I want to express my perplexity with QTCreator. If I choose mywidget from the widgets selector one expect that Qtcreator does the work.
And, of course, I want to learn, and I try to do the things myself, but the QT documentations sometimes does not give me solutions.

So, my questions (unresolved) are

At this moment if I build myprog, how is used mywidget, statically ?
And to use the dll directly, Have I to use Qpluginloader?


Thanks.

wysota
15th March 2011, 11:37
I want to express my perplexity with QTCreator. If I choose mywidget from the widgets selector one expect that Qtcreator does the work.
What work?????


And, of course, I want to learn, and I try to do the things myself, but the QT documentations sometimes does not give me solutions.
What does Qt have to do with it? If your neighbour buys a car does it mean the salesman should automatically send one to you as well? Why should he?


At this moment if I build myprog, how is used mywidget, statically ?
I don't know what you mean by "used statically".


And to use the dll directly, Have I to use Qpluginloader?
No, you have to link your application against the library.

Forget QtCreator, forget Qt, learn to use pure C++ as your questions and problems are totally unrelated to Qt. I don't know what your imaginations about Qt or Creator are but they are completely wrong. Qt Creator will not do programming for you, it will not learn programming for you, it will not design your software for you. If you want to be a software developer then FIRST learn how to develop software and THEN become a software developer, not the other way round.

tonnot
15th March 2011, 12:19
Sincerely Wysota, I dont deserve your comments about me.
If you want, please tell me some useful or shut up, because this is a forum to help people not to laugh of anyone.

1.- I have mylugin with their dll.
2.- I see my customwidgets at designer
3.- I choose one of them and drop onto my form
Here is where I have my doubts.
- I have to add manually the .h and cpp to my pro file (I think Qtcreator must to do it). In this scenario I am using 'statically' my widget (My application are not using the dll).
- So, I want to use the dll (where the mywidgtes are) and I dont know how to do it :
Must I use Q_DECL_EXPORT and Q_DECL_IMPORT ?
Must I use QpluginLoader?

I dont see any example of how to do this at Qt docs, so this is the reason because I ask for help.
Thanks

high_flyer
15th March 2011, 12:58
@tonnot:
do you know how to link against a library?
From you posts it seems you don't.
You have to first learn and understand how linking is done and what it means in general, with out Qt.
You will then discover, you can link libs in Qt projects as well.
This forum as you said is for helping with Qt related problems.
But you problem is not Qt related, but one of general understanding of what linking is, and how it is done, therefore, your posts are off topic.
Once you understand how linking works, come back again, and ask specific questions if you still have trouble.
This forum is NOT about teaching people basic concepts such as building and linking C++ projects.

wysota
15th March 2011, 13:36
because this is a forum to help people not to laugh of anyone.
"Help" - yes, "do work for others" - no.


I think Qtcreator must to do it
Why would Creator do it? Designer plugins are just that - plugins for Designer. They have nothing to do with your application, why would Creator add something to your application when you drop some widget on some form? How would it know what files to add, where to find them and how to add them? How would it know you want them added at all?


I dont see any example of how to do this at Qt docs, so this is the reason because I ask for help.
Let me repeat myself again - using libraries with Qt is exactly similar as using them without Qt hence Qt docs don't have such detailed information. The same as they don't contain information how to install an operating system, how to save a file, how to name the file and they don't contain a complete course for learning C++. This is your responsibility to learn all that. Qt docs only tell you HOW to add a library to a project, they don't focus on how to use the library because you should already know that. Learn to walk before you start running.

Qt docs contain a "Creating Shared Libraries" section as well as instructions how to link against a DLL using qmake. They also contain a page about "Creating Custom Widgets for Qt Designer" with detailed instructions on how to split the plugin into two parts.

And again - a "Designer plugin" is exactly that - it is a plugin for handling a custom widget in Designer and not in your application.

tonnot
15th March 2011, 14:01
I remember the VB6 I use in 1995? 16 years ago ?
You could to build an ocx, and It was available inmediatly to be dropped and used onto a form.
And all the work was made .... And if you modified something the changes was seen inmediatly.
Java.... You develop a visual class and just use it...

So, I dont understand how QTcreator does not make it...

Ok, WY and thanks for all.

wysota
15th March 2011, 14:40
I remember the VB6 I use in 1995? 16 years ago ?
You could to build an ocx, and It was available inmediatly to be dropped and used onto a form.
And all the work was made .... And if you modified something the changes was seen inmediatly.
Then go back to VB6. If it's so great what do you need Qt/C++ for?


Java.... You develop a visual class and just use it...
No... not really. You still need to add it to your project.


So, I dont understand how QTcreator does not make it...
Ok, a simple experiment. I have the following directory structure:
/myprojects/someProject/table.cpp
/myprojects/libs/coolStuff/includes/table.h
/myprojects/libs/coolStuff/table.h
/myprojects/libs/coolStuff/sources.cpp
/myprojects/libs/coolStuff/includes/backup/table.h
/myprojects/libs/non-coolStuff/includes/table.h
/myprojects/branches/libs/coolStuff/includes/backup/table.h
/myprojects/branches/libs/coolStuff/sources.cpp
/myprojects/lib/libmywidgets.so

I have a custom widget plugin that says it requires a "table.h" header. I also have a project in /tmp/myNewProject where I create a file myform.ui and drop the custom widget on the form. Which files should QtCreator add to my project?

tonnot
15th March 2011, 14:56
I'dont understand you. You could to have answered ' Yes, Qtcreator must to have a wizard to do the job' .
But dont worry, When I have it clear, I'm going to write an easy tutorial for it.
Thanks

wysota
15th March 2011, 15:00
I'dont understand you.
Please answer my question:

Which files should QtCreator add to my project?

You are smarter than a machine so it should be easier for you to decide which files are needed than for a machine. So, which ones?


You can simply answer ' Yes, Qtcreator must to have a wizard to do the job'
What job? Sometimes you need to add some files and sometimes you don't. What would a wizard change here besides annoying the user who knows what he's doing?


But dont worry, When I have it clear, I'm going to write an easy tutorial for it.
Don't bother. Most people know you have to actually have the implementation of the widget available to use it. Since there are different situations in real world, an "easy tutorial" might just lead people with a different situation from yours the wrong path.