当前位置:网站首页>Qdebug June 2022

Qdebug June 2022

2022-06-25 04:50:00 Gongjianbo

One 、Qt Widgets Problem communication

Two 、Qt Quick Problem communication

1.QML The program does not start properly on some graphics cards  

Environmental Science :Window10  MSVC2019  Qt5.15.2-64bit( Lower versions will also )

The phenomenon : The notebook + The expansion screen has two screens ,Windows The main screen of the setting can normally display QML Of Window window , The auxiliary screen will be stuck during startup ( A black or white window is stuck there ; The default operation focus will pop up on which screen , So the program can be started by dragging it to the corresponding screen ). Disable the integrated graphics card that comes with the notebook , The main screen and auxiliary screen can be started normally .

Later learned Qt You can set the blacklist of the graphics card .Qt Quick application OpenGL The order of implementation is desktop,angle,software, To use Qt Quick 2 Work needs to be provided OpenGL2.1 And above , This requires disabling some pairs of   OpenGL Support problematic graphics cards , And then use angle perhaps software .

Qt file :https://doc.qt.io/qt-5/windows-requirements.html

my Demo:https://github.com/gongjianbo/MyTestCode2021/tree/master/Qml/OpenGLBlackList

Write the problematic graphics card information to a json In file , And then in the environment variable QT_OPENGL_BUGLIST Appoint json Path to file ( To facilitate the resource file path I use here ):

{
    "name": "Qt built-in GPU driver blacklist",
    "version": "5.14",
    "entries": [
        {
           "id": 1,
           "description": "Intel(R) UHD Graphics",
           "vendor_id": "0x8086",
           "device_id": ["0x9ba4"],
           "os": {
               "type": "win"
           },
           "features": [
               "disable_desktopgl"
           ]
        }
    ]
}
int main(int argc, char *argv[])
{
    qputenv("QT_OPENGL_BUGLIST", ":/opengl-blacklist.json");
    QGuiApplication app(argc, argv);
    ... ...
    return app.exec();
}

This type of graphics card is disabled in the settings desktop opengl, Will try angle and software The implementation of the .

json File each graphics card mainly distinguishes two parameters , manufacturer id And equipment id, It can be downloaded from Windows View... In device manager , This VEN The last four hexadecimal digits are the manufacturers id, DEV The next four hexadecimal digits are the device id:

  

There are many types of graphics cards that may be incompatible , It will be updated to the blacklist .

2.QML FileDialog Pick up to url The path is formatted as a local path

QML Of FileDialog The obtained file or directory path is url Format , Except that the path is preceded by "file:///"  start , And escape #%^{} Equal special symbol .

Qt C++ Of QUrl Class provides two interfaces for url Conversion with local path format :

//url Convert to local path 
QString QUrl::toLocalFile() const
// Generate based on local path url
QUrl QUrl::fromLocalFile(const QString &localFile) //static

3、 ... and 、 other

1.QString Remove blanks

    QString str=" a b\t\tc\n\nd ";
    // Remove any white space 
    str.remove(QRegularExpression("\\s")); //"abcd"
    str.remove(QRegExp("\\s")); //"abcd"
    // Remove the head blank 
    str.remove(QRegExp("^ +\\s*")); //"a b\t\tc\n\nd "
    // Remove trailing blanks 
    str.remove(QRegExp("\\s* +$")); //" a b\t\tc\n\nd"
    // Remove the blank on both sides 
    str=str.trimmed(); //"a b\t\tc\n\nd"
    // Remove the blank on both sides , And replace the internal white space with a single space 
    str=str.simplified(); //"a b c d"
    qDebug()<<str;

2.FTH: ( Numbers ): ***Fault tolerant heap shim applied to current process. This is usually due toprevious crashes. ***

Microsoft documentation :https://docs.microsoft.com/en-us/windows/win32/win7appqual/fault-tolerant-heap

Qt Creator The error prompt appears when running the program in , Most likely, the runtime crashed before . After the error prompt appears, you need to modify the registry to set , Otherwise, this error will be prompted every time .

Refer to Microsoft documentation , Fault tolerant heap (Fault Tolerant Heap,FTH) yes Windows 7 A subsystem of , Responsible for monitoring application crashes and autonomously applying mitigation measures , To prevent future crashes on every application . But I didn't find any specific use , Should it collapse or will it collapse .

First find the registry FTH Set up :

 Computer \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\FTH

take Enabled One from 1 Set to 0( I also took FTH/State A message under the directory that is the same as the program name is deleted )

The document says restart the computer after setting ,FTH Will no longer activate for new applications ( But the actual measurement does not restart and there is no problem )

After setting, execute CMD Command to clear all FTH Application records :

Rundll32.exe fthsvc.dll,FthSysprepSpecialize

原网站

版权声明
本文为[Gongjianbo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250402133466.html