Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Multiple hyperlinks in one label text
Forum Updated to NodeBB v4.3 + New Features

Multiple hyperlinks in one label text

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raadush
    wrote on last edited by
    #1

    Hi guys,
    I have this question. I can simply evaluate hyperlink in label text by using linkActivated like in this example:

    @label->setText("Some message. <ahref=" ">Agree</a>");
    connect(label, SIGNAL(linkActivated(const QString & )), this, SLOT(agree()));
    @
    But is there some way to react on multiple hyperlinks in one label text differently? Let say I have:
    @
    label->setText("Some message. <ahref=" ">Agree</a>, or you can always <ahref=" ">Cancel</a>.");
    @
    And all I want do do is to connect signal from hyperlink Agree to agree() slot and signal from hyperlink Cancel to cancel() slot.
    Thanks ;)
    -(btw I know I have some errors in sytax, but I had to change it a little for this post to be displayed correcly - meaning ahref and spaces after SIGNAL and SLOT)-

    Edit: Please use @ tags around code sections, that also solves your layout issue; Andre

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      The linkActivated() signal passes the clicked link, which makes it rather easy to react differently (given that meaningful link names are provided).
      @
      setText("<a href='agree'>Agree</a>, or you can always <a href='cancel'>Cancel</a>.");

      void activateLink(const QString &link)
      {
      if (link == "agree")
      {
      agree();
      }
      else if (link == "cancel")
      {
      cancel();
      }
      }
      @

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved