用默认程序打开txt文件 [英] Open txt file with default program

查看:196
本文介绍了用默认程序打开txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,我有一个按钮,我想在相对目录中打开一个文本文件。我正在使用这样的QDesktopServices:

In my program, I have a button that I want to open a text file in a relative directory. I'm using QDesktopServices like this:

QDesktopServices::openUrl(QUrl::fromLocalFile("file:///stuff/block_settings.txt"));

当按下按钮时,没有任何反应。

When the button is pressed, nothing happens.

该文件位于与我的.exe相同位置的名为stuff的文件夹中。这是与我所有其他任务相同的目录。

The file is in a folder named "stuff" that resides in the same location as my .exe. It is the same directory used for all my other tasks.

我做错了什么?

谢谢。

推荐答案

我解决了这个问题。更改为:

I fixed the issue. Changed to:

QDesktopServices::openUrl(QUrl("file:stuff\\block_settings.txt"));

不知道该如何工作,因为我没有看到任何教程的任何地方的配置

Not sure how that works because I don't see that configuration on any tutorial anywhere but w/e

这篇关于用默认程序打开txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆