Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
QtHelper.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19 **=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#pragma once
25
26#include <QCoreApplication>
27#include <QFile>
28#include <QString>
29
30#include <Inventor/SoPreferences.h>
31#include <Inventor/helpers/SbFileHelper.h>
32#include <Inventor/sys/SoDynamicLibManager.h>
33
42{
43public:
58 static void
59 addPlatformPluginsPath( QString path = "" )
60 {
61 // if the QApplication alraady exists, we can safely assume everything is in order
62 // if there is a qt.conf file, we do not want to apply our library path modifications
63 // as we should trust the qt.conf to do everything that is required.
64 const bool qtconfExists = QFile::exists( "qt.conf" );
65 if ( qApp || qtconfExists )
66 return;
67
68 if ( SoPreferences::getString( "QT_QPA_PLATFORM_PLUGIN_PATH", "" ).isEmpty() )
69 {
70 if ( path.isEmpty() )
71 {
72 // Try to guess QT platforms path from Open Inventor binaries path
73 const QString pluginPath = qtPluginsPath();
74 if ( SbFileHelper::isAccessible( pluginPath.toStdString() ) )
75 {
76 QCoreApplication::addLibraryPath( pluginPath );
77 }
78 }
79 else
80 {
81 QCoreApplication::addLibraryPath( path );
82 }
83 }
84 }
85
90 static QString
92 {
93 const SbString binariesPath = SoDynamicLibManager::getLibraryFromSymbol( ( void* )SoInventorBase::init );
94 const QString qtPlatformsPath = SbFileHelper::toUnixPath( SbFileHelper::getDirName( binariesPath ) + "qtplugins/" ).toStdString().c_str();
95 return qtPlatformsPath;
96 }
97};
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Utilities class ...
Definition QtHelper.h:42
static void addPlatformPluginsPath(QString path="")
When a Qt5 application is run, Qt will first treat the application's executable directory as the base...
Definition QtHelper.h:59
static QString qtPluginsPath()
Returns the path of the Qt storage plugin.
Definition QtHelper.h:91
static SbString getDirName(const SbString &fullFilePath)
Returns the directory path part of a full path string.
static SbBool isAccessible(const SbString &filename, FileAccess mode=READ)
Returns TRUE if a file is accessible
static SbString toUnixPath(const SbString &path)
Converts a Microsoft Windows path (with '\') to a Unix path (with '/').
Class for smart character strings.
Definition SbString.h:202
std::string toStdString() const
Returns the string as an STL string.
static SbString getLibraryFromSymbol(void *symbol)
Returns the full path of the library that contains the given symbol.
static SoNONUNICODE const SbString & getString(const char *name, const SbString &defaultValue)
Returns the value of the specified environment variable in the Open Inventor environment.