00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #pragma once 00025 00026 #include <QCoreApplication> 00027 #include <QFile> 00028 #include <QString> 00029 00030 #include <Inventor/SoPreferences.h> 00031 #include <Inventor/helpers/SbFileHelper.h> 00032 #include <Inventor/sys/SoDynamicLibManager.h> 00033 00041 class QtHelper 00042 { 00043 public: 00058 static void 00059 addPlatformPluginsPath( QString path = "" ) 00060 { 00061 // if the QApplication alraady exists, we can safely assume everything is in order 00062 // if there is a qt.conf file, we do not want to apply our library path modifications 00063 // as we should trust the qt.conf to do everything that is required. 00064 const bool qtconfExists = QFile::exists( "qt.conf" ); 00065 if ( qApp || qtconfExists ) 00066 return; 00067 00068 if ( SoPreferences::getString( "QT_QPA_PLATFORM_PLUGIN_PATH", "" ).isEmpty() ) 00069 { 00070 if ( path.isEmpty() ) 00071 { 00072 // Try to guess QT platforms path from Open Inventor binaries path 00073 const QString pluginPath = qtPluginsPath(); 00074 if ( SbFileHelper::isAccessible( pluginPath.toStdString() ) ) 00075 { 00076 QCoreApplication::addLibraryPath( pluginPath ); 00077 } 00078 } 00079 else 00080 { 00081 QCoreApplication::addLibraryPath( path ); 00082 } 00083 } 00084 } 00085 00090 static QString 00091 qtPluginsPath() 00092 { 00093 const SbString binariesPath = SoDynamicLibManager::getLibraryFromSymbol( ( void* )SoInventorBase::init ); 00094 const QString qtPlatformsPath = SbFileHelper::toUnixPath( SbFileHelper::getDirName( binariesPath ) + "qtplugins/" ).toStdString().c_str(); 00095 return qtPlatformsPath; 00096 } 00097 }; 00098