<legend id='fS6az'><style id='fS6az'><dir id='fS6az'><q id='fS6az'></q></dir></style></legend>
  • <tfoot id='fS6az'></tfoot>

      <bdo id='fS6az'></bdo><ul id='fS6az'></ul>

    <small id='fS6az'></small><noframes id='fS6az'>

        <i id='fS6az'><tr id='fS6az'><dt id='fS6az'><q id='fS6az'><span id='fS6az'><b id='fS6az'><form id='fS6az'><ins id='fS6az'></ins><ul id='fS6az'></ul><sub id='fS6az'></sub></form><legend id='fS6az'></legend><bdo id='fS6az'><pre id='fS6az'><center id='fS6az'></center></pre></bdo></b><th id='fS6az'></th></span></q></dt></tr></i><div id='fS6az'><tfoot id='fS6az'></tfoot><dl id='fS6az'><fieldset id='fS6az'></fieldset></dl></div>
      1. 在 QLabel 中插入可点击链接并检测点击此链接以引发操作

        时间:2023-10-18

              <legend id='2LrnY'><style id='2LrnY'><dir id='2LrnY'><q id='2LrnY'></q></dir></style></legend>

            • <i id='2LrnY'><tr id='2LrnY'><dt id='2LrnY'><q id='2LrnY'><span id='2LrnY'><b id='2LrnY'><form id='2LrnY'><ins id='2LrnY'></ins><ul id='2LrnY'></ul><sub id='2LrnY'></sub></form><legend id='2LrnY'></legend><bdo id='2LrnY'><pre id='2LrnY'><center id='2LrnY'></center></pre></bdo></b><th id='2LrnY'></th></span></q></dt></tr></i><div id='2LrnY'><tfoot id='2LrnY'></tfoot><dl id='2LrnY'><fieldset id='2LrnY'></fieldset></dl></div>
                <tfoot id='2LrnY'></tfoot>
                • <bdo id='2LrnY'></bdo><ul id='2LrnY'></ul>
                    <tbody id='2LrnY'></tbody>
                • <small id='2LrnY'></small><noframes id='2LrnY'>

                  本文介绍了在 QLabel 中插入可点击链接并检测点击此链接以引发操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想处理对我的这个应用程序中的链接的点击:

                  I would like to handle a click to the link in this application of mine:

                  当我点击输出文件"链接时,我希望能够在我的应用程序中生成一个操作.

                  When I click on the "Output File" link, I would like to be able to generate an action in my application.

                  截至今天,链接在富文本QLabel中是这样描述的:

                  As of today, the link is described like this in the rich text QLabel:

                  <a href="http://google.fr"><span style=" text-decoration: underline; color:#0000ff;">Output File&quot;</span></a>
                  

                  (由 Qt Designer 生成)

                  (generated by Qt Designer)

                  点击后,它会打开默认的网络浏览器去谷歌.那不是我想要的;我想要类似的东西:

                  When clicked, it will open the default web browser to go to Google. That's not what I want; I'd like something like:

                  <a href="#browse_output"><span style=" text-decoration: underline; color:#0000ff;">Output File&quot;</span></a>
                  

                  并且能够检测到点击的链接并做出相应的反应:

                  And be able to detect the link that's clicked and react accordingly:

                  (pseudo code)
                  
                  if( link_clicked.toString() == "#browse_output" ){
                      on_browse_output_clicked();
                  }
                  

                  这在带有 QLabel(或接近的东西)的 Qt 中是可能的吗?怎么样?

                  Is this possible in Qt with a QLabel (or something approaching) ? How?

                  推荐答案

                  好的,有兴趣的朋友,我得到了答案:

                  Ok, for those interested, I got the answer:

                  1. 禁用QLabel
                  2. openExternalLinks"属性
                  3. QLabel 的信号 linkActivated 连接到您的处理程序.
                  1. Disable the "openExternalLinks" property of the QLabel
                  2. Connect the signal linkActivated of the QLabel to your handler.

                  就是这样:linkActivated 为您提供了链接在参数中引用的 URL,因此我的伪代码可以完美运行.

                  That's all: linkActivated gives you the URL that the link refers to in argument, so my pseudo code works perfectly.

                  // header
                  private slots:
                    void on_description_linkActivated(const QString &link);
                  
                  // cpp
                  void KernelBuild::on_description_linkActivated(const QString &link)
                  {
                    if( link == "#browse_output" ){
                      on_outfilebtn_clicked();
                    }
                  }
                  

                  这篇关于在 QLabel 中插入可点击链接并检测点击此链接以引发操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:体系结构 x86_64 的未定义符号:编译问题 下一篇:通过 QML 函子对 C++ 模型进行排序和过滤?

                  相关文章

                    <legend id='W3Pwg'><style id='W3Pwg'><dir id='W3Pwg'><q id='W3Pwg'></q></dir></style></legend>
                    <tfoot id='W3Pwg'></tfoot>
                    <i id='W3Pwg'><tr id='W3Pwg'><dt id='W3Pwg'><q id='W3Pwg'><span id='W3Pwg'><b id='W3Pwg'><form id='W3Pwg'><ins id='W3Pwg'></ins><ul id='W3Pwg'></ul><sub id='W3Pwg'></sub></form><legend id='W3Pwg'></legend><bdo id='W3Pwg'><pre id='W3Pwg'><center id='W3Pwg'></center></pre></bdo></b><th id='W3Pwg'></th></span></q></dt></tr></i><div id='W3Pwg'><tfoot id='W3Pwg'></tfoot><dl id='W3Pwg'><fieldset id='W3Pwg'></fieldset></dl></div>

                    <small id='W3Pwg'></small><noframes id='W3Pwg'>

                    • <bdo id='W3Pwg'></bdo><ul id='W3Pwg'></ul>