Results 1 to 3 of 3

Thread: plugin in a library

  1. #1
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default plugin in a library

    hi,

    i have been trying to import plugins to a library and link that library to another application.

    the library pro file is as the following:
    Qt Code:
    1. TEMPLATE = lib
    2. HEADERS += testFile.h
    3. SOURCE += testFile.cpp
    4. CONFIG += debug static
    5. RESOURCES += testFile.qrc # the images are stored as resources
    6. QTPLUGIN += qjpeg
    To copy to clipboard, switch view to plain text mode 

    I use the Q_IMPORT_PLUGIN(qjpeg) in the library source file.

    the content of the application pro file is as follows:
    Qt Code:
    1. TEMPLATE = app
    2. SOURCES += main.cpp
    3. CONFIG += debug qt x11
    4. LIBS += libTestFile.a # the library mentioned above
    To copy to clipboard, switch view to plain text mode 

    the code block is as follows:
    Qt Code:
    1. int main(int argc, char* argv[])
    2. {
    3. QApplication app(argc, argv);
    4. testFile file1; // constructs a toolbar having an icon (a jpeg image is used as icon)
    5. file1.show(); // shows the toolbar
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    without using the libraries and embedding the library code into the application code, the jpeg file is displayed correctly.

    when using libraries, the jpeg plugin's static library is not linked to my library and when I compile the application, I get an error message regarding the Q_IMPORT_PLUGIN (undefined reference to qt_plugin_instance_qjpeg()). when I add
    Qt Code:
    1. QTPLUGIN += jpeg
    To copy to clipboard, switch view to plain text mode 
    to the pro file of the application, the application is built but the image is not visible on the toolbar.

    how can I embed the images to the library and use it in the application ?

  2. #2
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plugin in a library

    I have found the reason why the image is not displayed.

    since the resource is linked to a static library, it is necessary to call
    Qt Code:
    1. Q_INIT_RESOURCE(resourceName)
    To copy to clipboard, switch view to plain text mode 

    in the application in order to use the resources properly.

  3. #3
    Join Date
    May 2008
    Posts
    61
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plugin in a library

    is it possible to link the jpeg library to the custom created library or is it a must to link it to the main application ?

Similar Threads

  1. Plugin implementation question
    By JPNaude in forum Qt Programming
    Replies: 12
    Last Post: 27th August 2008, 20:24
  2. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 14:13
  3. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  4. Qt4 win opensource + mysql plugin
    By vr in forum Installation and Deployment
    Replies: 3
    Last Post: 25th May 2007, 09:01
  5. Replies: 1
    Last Post: 5th March 2007, 20:50

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.