PDA

View Full Version : Class inclusion



denim83
18th June 2010, 04:58
Dear all,

How do i reuse an existing class? i've already included the header file & given include path in makefile. Still i'm getting linking error of "undefined reference to". How to solve this problem?

Regards,
abhishek

denim83
18th June 2010, 06:58
#include "browser/browserapplication.h"

int main(int argc, char *argv[])
{
BrowserApplication *bapp = new BrowserApplication(argc, argv);
bapp->newMainWindow();
bapp->exec();
}

i'm getting following errors:

main.o: In function `main':
main.cpp:(.text+0x2b6): undefined reference to `BrowserApplication::BrowserApplication(int&, char**)'
main.cpp:(.text+0x3fa): undefined reference to `BrowserApplication::newMainWindow()'
collect2: ld returned 1 exit status
make: Leaving directory `/opt/qtsdk-2010.02/qt/demos/ebook'
make: *** [ebook] Error 1
Exited with code 2.
Error while building project ebook
When executing build step 'Make'

Zlatomir
18th June 2010, 07:17
What is browserapplication.h? Did you write it yourself?

If it is the one from Qt's example code it has a main.cpp and a project file (browser.pro) Use open project (from Qt Creator) to open and build that project file.

denim83
18th June 2010, 07:19
That headerfile is from Qt's example code. That project is building independently. ii want to reuse the BrowserApplication class in my application. i want to call its methods from my app.

Zlatomir
18th June 2010, 07:31
For that you will need to add to your project at least browserapplication.h and browserapplication.cpp
But that class will use other classes form their project (you will need that classes too)

I recommend to study the code and write your own reusable code. (that particular class won't be so "reusable" because it creates the qapplication and mainwindow in it's code)

denim83
18th June 2010, 10:10
Is there anyway to launch this browser by connecting it to a button? Or how to link QDesktopServices to a button?

Zlatomir
18th June 2010, 12:24
You can launch an external application (browser in this case) from your application using QProcess (http://doc.trolltech.com/4.6/qprocess.html), but i don't think this is what you want.

Or if you want to render web pages in your application, you can use use webkit (http://doc.qt.nokia.com/4.6/qtwebkit.html)
If you explain what you want to achieve, maybe we can give better advices.

denim83
18th June 2010, 12:53
i want to load a specific file in a browser by clicking a button in my app.