How to use dynamic plugin libqtiff.so in Qt 5.10.0



  • Hello,

    I'm writing a desktop application to manipulate satellite based images. Mostly, these images come in tiff format. I am hoping to use the built-in libqtiff.so plugin to provide support to open and display tiff images in Qt. However, I have found the documentation on this subject to be incomplete. Can someone point me in the right direction of how to link a dynamic plugin into my Qt application?

    The plugins are in Q/t5.10.0/gcc_64/plugins/imageformats and that is where my application looks for plugins.

    Is there something I need to add to my .pro file to get this plugin to run? Is there a way to check if it has actually been built? It seems like using built-in plugins should be pretty painless, but I'm fairly stumped at this point. Any help would be greatly appreciated.

    Thanks in advance


  • Lifetime Qt Champion

    Hi,

    Nothing special to do. Use QImage to open your .tiff files. It will automatically load the plugin matching the file format for you.



  • Are there any things that could be causing the .tiff files to not show up in a QFileDialog window? I've tried using QImage as well as QPixmap to store the image files, but .tiff files do not show up. Other formats (.jpg to be specific) do show up, so I know the file dialog is working.

    Do I need to link against the libqtiff.so file in my .pro file, like other dynamic libraries?


  • Lifetime Qt Champion

    No. A plugin is loaded at run time.

    You can set the QT_DEBUG_PLUGINS environment variable to 1 and re-run your application. You should get more information about what is happening with the tiff plugin.



  • Sounds good. I will do that when I get home tonight and report back if I have questions. Thanks, @SGaist !



  • After adding

    qputenv("QT_DEBUG_PLUGINS", QByteArray("1"));
    

    To main.cpp before QApplication, here is the output once I actually try to open a file via QFileDialog:

    Got keys from plugin meta data ("webp")
    QFactoryLoader::QFactoryLoader() checking directory path "/home/seth/Documents/qt_projects/build-tiny_NDVI-Desktop_Qt_5_10_0_GCC_64bit-Debug/imageformats" ...
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqgif.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqicns.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqico.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqjpeg.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqsvg.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqtga.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqtiff.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqwbmp.so"
    loaded library "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqwebp.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqgif.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqicns.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqico.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqjpeg.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqsvg.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqtga.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqtiff.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqwbmp.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/imageformats/libqwebp.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/platforminputcontexts/libibusplatforminputcontextplugin.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/platformthemes/libqgtk3.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/xcbglintegrations/libqxcb-glx-integration.so"
    QLibraryPrivate::unload succeeded on "/home/seth/Qt/5.10.0/gcc_64/plugins/platforms/libqxcb.so"
    QLibraryPrivate::unload succeeded on "Xcursor" (faked)

    So it looks like the plugins are loading succesfully, but I still can't see the tiff images via Qt.

    Here is the code I'm using to access the files, if that helps at all:

    const QString& fileName = QFileDialog::getOpenFileName(this, "Open Image", "/home/seth", "Image Files (*.TIF, *.tif, *.tiff, *.TIFF, *.jpg)");
    QImage image;
    image.load(fileName);
    


  • I've gotten it working! Thanks for your help @SGaist . Much appreciated. It looks like the images I'm working with are actually GeoTIFF, not true tiff, so that is where the issue was. Once I downloaded a .tif, I could see and open it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.