如何使QGraphicsTextItem可点击? [英] How to make a QGraphicsTextItem clickable?

查看:1245
本文介绍了如何使QGraphicsTextItem可点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的软件的关于框中,我使用 QGraphicsTextItem 来显示有关文本。

In the "About box" of my software, I used a QGraphicsTextItem to show the about-text.

此文本包含超文本链接(格式为:< a href =http://some.random.site> link< / a> ) 。

This text contains hypertext links (in the form of: <a href="http://some.random.site">link</a>).

该项目正确显示(超文本链接为蓝色并带下划线)。但是,当我点击它们时,没有任何反应。

The item shows up properly (hypertext links are blue and underlined). However, when I click on them, nothing happens.

以下是我创建 QGraphicsTextItem 的方法:

d_about_text_item = new QGraphicsTextItem;
d_about_text_item->setTextInteractionFlags(Qt::TextBrowserInteraction);
d_about_text_item->setHtml(aboutText());

据我所知 Qt文档,对 setTextInteractionFlags 的调用应该允许我处理特殊的超文本链接点击事件。

As I understand the Qt documentation, the call to setTextInteractionFlags should allow me to handle special hypertext links click events.

我还有什么办法可以点击链接并在默认系统浏览器中显示链接页面吗?

Is there anything else I should do to be able to click on the links and show up the linked page in the default system browser ?

推荐答案

我发现我做错了:

我的包含 QGraphicsView 已将 setInteractive()设置为 false 。我删除它,从现在开始,它工作正常。

My containing QGraphicsView had setInteractive() set to false. I removed it and since now, it works fine.

这篇关于如何使QGraphicsTextItem可点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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