Insert clickable link in QLabel and detect click on this link to provoke an action

前端 未结 1 1938
刺人心
刺人心 2021-01-01 15:53

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

\"my

When I click

相关标签:
1条回答
  • 2021-01-01 16:46

    Ok, for those interested, I got the answer:

    1. Disable the "openExternalLinks" property of the QLabel
    2. Connect the signal linkActivated of the QLabel to your handler.

    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();
      }
    }
    
    0 讨论(0)
提交回复
热议问题