Hello to all. There is a pushButton button and there is a file, it does not matter html pdf doc (Vordovsky). As by clicking on the button, open this file, just as we click on it with the mouse 2 times and it is launched by Microsoft Office Word if it is a dock, Pdf Viewer if it is pdf, html if it is a browser, you just need a button from the Gui program. The path to the file for example is C: \ book. And is it possible to push such data file formats into a resource project files? to load from it?

  • no, I don't need OpenFileDialog and its window, the file path is static. How stumbled on right now you can use QProcess. - Disastricks
  • Understood, then exec, shellexecute, winexec or in extreme cases openprocess - nick_n_a
  • From the resources it is theoretically possible but not all. Not all applications work correctly with the res: protocol. In some COM ActiveX, you can dynamically load a document, but this is a different kind of discovery (cf OleRun, CoCreateInstance IOleSite functions). - nick_n_a
  • Thanks, I read about it for general development, and if I want the application to be cross-platform? here everything except for exec under Windows, as I understood. - Disastricks
  • Right now, I am developing under Windows, but the application should work on Linux. - Disastricks

1 answer 1

To open files as if they were double clicked in Explorer, use the QDesktopServices :: openUrl method . To get a QUrl that points to a local file, use the QUrl :: fromLocalFile method .

To open a file from resources, do the same as archivers open files - copy a file from resources to a temporary folder and open it.