Results 1 to 8 of 8

Thread: Class inclusion

  1. #1
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Class inclusion

    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

  2. #2
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Class inclusion

    #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'

  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Class inclusion

    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.

  4. #4
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Class inclusion

    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.

  5. #5
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Class inclusion

    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)

  6. #6
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Class inclusion

    Is there anyway to launch this browser by connecting it to a button? Or how to link QDesktopServices to a button?

  7. #7
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Class inclusion

    You can launch an external application (browser in this case) from your application using QProcess, 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
    If you explain what you want to achieve, maybe we can give better advices.

  8. #8
    Join Date
    Jun 2010
    Posts
    5
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Class inclusion

    i want to load a specific file in a browser by clicking a button in my app.

Similar Threads

  1. 2 classes header file inclusion probleml !!
    By sujan.dasmahapatra in forum General Programming
    Replies: 4
    Last Post: 15th October 2009, 19:31
  2. Why doesn't Eclipse find a correct inclusion?
    By Cruz in forum Installation and Deployment
    Replies: 4
    Last Post: 1st October 2009, 12:25
  3. Replies: 3
    Last Post: 27th December 2008, 19:34
  4. dll file inclusion
    By omprakash in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2008, 19:41
  5. AVOIDING mutiple inclusion of header file???
    By pratik in forum General Programming
    Replies: 4
    Last Post: 10th July 2007, 14:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.