zoukankan      html  css  js  c++  java
  • Qt加载lib、dll的几种方式

    1. 加载DLL

    (1) pro种加载

    LIBS+=$$PWDXXX.dll

    (2) QLibrary

    QLibrary *libOCI = new QLibrary("F:\oracle\product\10.2.0\db_1\bin\oci.dll");
    //加载动态库
    libOCI->load();
    if (!libOCI->isLoaded())
    {
        printf("Load Oracle oci.dll failed! ");
        return 0;
    }

    ==>Qt生成的dll可以,但外部的dll不行

    (3) addLibraryPath

    QApplication::addLibraryPath("D:/Qt/Documents/build-FaceComparison-Desktop_Qt_5_9_8_MinGW_32bit-Release/release/");

    (4) QPluginLoader

     void MainWindow::ReadPluginsInfo( const QString & pluginsDirPath /*= ""*/ )
    {
        QString pluginsPath = pluginsDirPath;
        if (pluginsDirPath.isEmpty())
        {
            pluginsPath = QApplication::applicationDirPath();
        }
        QDir pluginsDir(pluginsPath);
        pluginsDir.cd("Plugins");

        QFileInfoList pluginsFile = pluginsDir.entryInfoList(QStringList() << "*.dll", QDir::Files);
        foreach(QFileInfo fileInfo, pluginsFile)
        {
            QPluginLoader loader(fileInfo.absoluteFilePath());
            bool isLoad = loader.isLoaded();
            QString info = loader.errorString();

            if (QObject * plugin = loader.instance())
            {
                qDebug() << isLoad;
            }
            else
            {
                qDebug() << loader.errorString();
            }
        }
    }

    QStringList paths = QCoreApplication::libraryPaths();

    
    
    
    
    
    

    2. 加载lib

    //运行目录获取

        QString applicationDirPathStr = QApplication::applicationDirPath();
        qDebug() << "----------运行目录获取-------------"<<applicationDirPathStr;
    
    
        //运行环境目录获取
        QString applicationDirPathStr2 = QDir::currentPath();
        qDebug() << "----------运行环境目录获取-------------"<<applicationDirPathStr2;


  • 相关阅读:
    ucos信号量
    uC/OSII 常用函数参考手册
    GPS NMEA0183协议详解
    为sql server 表数据生成创建的储存过程(生成insert 脚本)
    安装SQL2008,提示删除SQL2005Express工具的解决方法
    intel hex 文件格式解密
    C语言:I/O
    C语言基础
    摆脱IDE进行时. . .
    对WinForm的App.config文件进行加密
  • 原文地址:https://www.cnblogs.com/xiang--liu/p/12912226.html
Copyright © 2011-2022 走看看