开发者

How to set which browser to use in a QTextBrowser link?

I am using PyQt4's QTextBroswer to display a html link.

Whenever users click on the link, a browser will be used to open the internet page.

My question is, is there a way to set so that our own prefered browser is used to open the ur开发者_如何学编程l page instead of the preset one?

Thanks in advance.


QTextBrowser provides an actual browser. If you want to open a document in the user's desktop environment-specified browser, then you'd use QDesktopServices::openUrl.

You can use QProcess to start random programs:

QObject *parent;
...
QString program = "/path/to/browser";
QStringList arguments;
arguments << "--your-browser-url-option-if-any" << "http://www.example.com";

QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);


I am not sure if this will help you or this is what you were looking for. I found that by setting the openExternalLinks flag to True I was able to get the link to open in Firefox. I just called the setOpenExternalLinks method with True as argument.

This method is only for using the default browser and won't let you to actually set the browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜