Hello to all! Interested in solving this issue. There is a code:

QString path = QApplication::applicationDirPath() + "/readme/1.pdf"; 

Next, I use the check for the existence of a file.

 if(!File::exists(path)) { QMessageBox msgBox; msgBox(trUtf8("Невозможно открыть файл") + path + trUtf8(" Файл не существует!")); msgBox.setIcon(QMessageBox::Warning); msgBox.exec(); } 

File launch:

 QDesktopServices::openUrl(QUrl(path, QUrl::TolerantMode)); 

And now the question ... How to check if there is no program to open the file on the computer? Now, if there is no program, a window is displayed. Windows could not open the file: Search for a match on the Internet, Selecting a program from the list of installed programs. I want to make it so that MessageBox would be displayed if the program with which the file can be opened is not installed on the computer. Check in style:

 if(!QDesktopServices::openUrl(QUrl(path, QUrl::TolerantMode))) 

Does not help. Displayed 2nd same window as above, with Windows, ie, they become 2.

    1 answer 1

    Open HKEY_CLASSES_ROOT\.pdf read the default parameter there, for example there will be "AcroExch.Document.DC". Then open HKEY_CLASSES_ROOT\AcroExch.Document.DC\shell\Open\command and read the default parameter there. There will be a program path for opening PDF. If there is no first or second key, there is no default program to open.

    • Thank. But do not tell me how to implement this check under linux? Where is the data stored there? need a cross-platform solution. - Disastricks
    • one
      @Disastricks Most likely it will not work, because Linux itself does not know anything about PDF at all. In KDE, there may be some opening settings, in GNOME - the second, in blackbox there will be no file manager and settings at all, and mc works in its own way. - Vladimir Martyanov