Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt在bash中找不到环境变量集_Bash_Qt_Ubuntu - Fatal编程技术网

Qt在bash中找不到环境变量集

Qt在bash中找不到环境变量集,bash,qt,ubuntu,Bash,Qt,Ubuntu,我有一个连接到它的摄像头,它有自己的API。为了获得工作代码,相机手册建议将这些环境变量添加到系统中 我在/etc/bash.bashrc中设置了以下内容 export PYLON_ROOT=/opt/pylon3 export GENICAM_ROOT_V2_3=${PYLON_ROOT}/genicam mkdir -p $HOME/genicam_xml_cache export GENICAM_CACHE_V2_3=$HOME/genicam_xml_c

我有一个连接到它的摄像头,它有自己的API。为了获得工作代码,相机手册建议将这些环境变量添加到系统中

我在/etc/bash.bashrc中设置了以下内容

    export PYLON_ROOT=/opt/pylon3
    export GENICAM_ROOT_V2_3=${PYLON_ROOT}/genicam

    mkdir -p $HOME/genicam_xml_cache
    export GENICAM_CACHE_V2_3=$HOME/genicam_xml_cache

    export LD_LIBRARY_PATH=${PYLON_ROOT}/lib64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64:${GENICAM_ROOT_V2_3}/bin/Linux64_x64/GenApi/Generic:$LD_LIBRARY_PATH
当我从终端运行我的qt代码时,代码运行没有任何错误。但是当我从Qtcreator运行它时,它会给我以下错误并终止程序

未找到环境变量“GENICAM\u ROOT\u V2\u 3”

我也在/etc/profile中添加了环境变量代码,但结果是一样的。为什么Qtcreator找不到我的变量

专业人士

Mainwindow.cpp

 MainWindow::MainWindow(QObject *parent) :QObject(parent)
{
    Initialize_Cam();
}
void MainWindow::Initialize_Cam()
{
    MonoCamThr = new MonoCamThread(this);
    MonoCamThr->Stop_Disp = true;
    MonoCamThr->start();
    MonoCamThr->Stop_Disp = false;
}
Monocam.cpp

MonoCamThread::MonoCamThread(QObject *parent) :
    QThread(parent)
{
    try
    {
        //  List of cameras
        DeviceInfoList_t m_Devices; // Still empty

        //  Create the unique transport layer factory object
        //  ... create the transport layer object
        //  ... create and initialise Cameras
        CTlFactory& TlFactory = CTlFactory::GetInstance();
        ITransportLayer *pTl = TlFactory.CreateTl( Camera_t::DeviceClass() );
        if ( ! pTl )
        {
            throw GenericException(
                "Failed to create transport layer!", __FILE__, __LINE__);
        }

        // Get all attached cameras and exit if no camera is found
        m_Devices.clear();
        if ( 0 == pTl->EnumerateDevices( m_Devices ) )
        {
            throw GenericException(
                "No camera present!", __FILE__, __LINE__);
        }
        if(m_Devices.size()<2)
        {
            while(1)
            {
                 qDebug() << "Number of Cameras are less than 2 .... \n" ;
            }
        }

            qDebug() << "Number of Cameras are: "<<m_Devices.size()<<" \n" ;
            // Restrict number of used camera
            size_t nCameras = 2;

            // Create all camera devices and set up the grab threads

            if(pTl->CreateDevice( m_Devices[0])->GetDeviceInfo().GetModelName())
            MonoCamera = new Camera_t( pTl->CreateDevice( m_Devices[1]) );


            MonoCamera->Open();

            MonoCamera->PixelFormat.SetValue( PixelFormat_Mono8 );
            MonoCamera->OffsetX.SetValue( 0 );
            MonoCamera->OffsetY.SetValue( 0 );
            MonoCamera->Width.SetValue( MonoCamera->Width.GetMax() );
            MonoCamera->Height.SetValue( MonoCamera->Height.GetMax() );
    }
    catch( GenericException &e )
    {
        qDebug() << "****  An exception occurred! Desription is: " << "\n"<< "    " << e.GetDescription() << "\n";
    }

}

void MonoCamThread::run()
{
    while(!Stop_Disp)
    {
//since this part of code never runs I didn' put the code for it ....
}
}
MonoCamThread::MonoCamThread(QObject*父对象):
QThread(父线程)
{
尝试
{
//摄像机列表
DeviceInfo列表\u t m\u设备;//仍然为空
//创建唯一的传输层工厂对象
//…创建传输层对象
//…创建并初始化摄影机
CTlFactory&TlFactory=CTlFactory::GetInstance();
ITransportLayer*pTl=TlFactory.CreateTl(Camera_t::DeviceClass());
如果(!pTl)
{
抛出泛型异常(
“创建传输层失败!”,_文件,_行_;);
}
//获取所有连接的摄像头,如果找不到摄像头,则退出
m_设备。清除();
如果(0==pTl->枚举设备(m_设备))
{
抛出泛型异常(
“没有摄像头!”,\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu;
}
if(m_Devices.size()OffsetY.SetValue(0);
monoamera->Width.SetValue(monoamera->Width.GetMax());
MonoCamera->Height.SetValue(MonoCamera->Height.GetMax());
}
捕获(一般例外和e)
{

qDebug()我正在将Qt与一个类似的cam一起使用。我已经设置了“运行设置”,如图所示


请显示您的代码。我的代码由14个cpp文件和15个hpp文件组成!!!显示我的代码到底是什么意思?@PsP在出现错误的地方发布相关代码。请检查项目->执行->环境是否包含您的变量。我记得QtCreator(早期的Qt5/QtCreator2.x)版本有时在解析变量时遇到问题。但这些问题将显示在应用程序的运行时环境设置中。
MonoCamThread::MonoCamThread(QObject *parent) :
    QThread(parent)
{
    try
    {
        //  List of cameras
        DeviceInfoList_t m_Devices; // Still empty

        //  Create the unique transport layer factory object
        //  ... create the transport layer object
        //  ... create and initialise Cameras
        CTlFactory& TlFactory = CTlFactory::GetInstance();
        ITransportLayer *pTl = TlFactory.CreateTl( Camera_t::DeviceClass() );
        if ( ! pTl )
        {
            throw GenericException(
                "Failed to create transport layer!", __FILE__, __LINE__);
        }

        // Get all attached cameras and exit if no camera is found
        m_Devices.clear();
        if ( 0 == pTl->EnumerateDevices( m_Devices ) )
        {
            throw GenericException(
                "No camera present!", __FILE__, __LINE__);
        }
        if(m_Devices.size()<2)
        {
            while(1)
            {
                 qDebug() << "Number of Cameras are less than 2 .... \n" ;
            }
        }

            qDebug() << "Number of Cameras are: "<<m_Devices.size()<<" \n" ;
            // Restrict number of used camera
            size_t nCameras = 2;

            // Create all camera devices and set up the grab threads

            if(pTl->CreateDevice( m_Devices[0])->GetDeviceInfo().GetModelName())
            MonoCamera = new Camera_t( pTl->CreateDevice( m_Devices[1]) );


            MonoCamera->Open();

            MonoCamera->PixelFormat.SetValue( PixelFormat_Mono8 );
            MonoCamera->OffsetX.SetValue( 0 );
            MonoCamera->OffsetY.SetValue( 0 );
            MonoCamera->Width.SetValue( MonoCamera->Width.GetMax() );
            MonoCamera->Height.SetValue( MonoCamera->Height.GetMax() );
    }
    catch( GenericException &e )
    {
        qDebug() << "****  An exception occurred! Desription is: " << "\n"<< "    " << e.GetDescription() << "\n";
    }

}

void MonoCamThread::run()
{
    while(!Stop_Disp)
    {
//since this part of code never runs I didn' put the code for it ....
}
}