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. Hyper-Link a QLabel?
Forum Updated to NodeBB v4.3 + New Features

Hyper-Link a QLabel?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 6.9k 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.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    I have 2 QLabel's in my Dialog.
    I want to hyper link both of them but with different behaviour.
    For the 1st one I want it to hyper link to a local folder.
    So that when the text in the QLabel is clicked it should open the folder in a new window.

    For the 2nd QLabel I want it to hyper link to a website.
    So that when the text in the QLabel is clicked it should open the default browser & open the link that I have specified in code.

    How do I do this?
    Thank You.

    1 Reply Last reply
    0
    • B Offline
      B Offline
      b1gsnak3
      wrote on last edited by
      #2

      Create a slot which will be connected to the QLabel::linkActivated(QString) signal... And there choose your destiny... If you don't want hassle to check the URL just make 2 slots, one for each QLabel and for each slot open the URL in a certain way... With QDesktopServices::openUrl(QUrl) for websites and for the other load the file where you wanted it to be loaded... And voila

      1 Reply Last reply
      0
      • CAD_codingC Offline
        CAD_codingC Offline
        CAD_coding
        wrote on last edited by
        #3

        Thank You b1gsnak3.
        On first look it seems my job is done.
        But I will get back to you tomorrow in case there is a problem.

        1 Reply Last reply
        0
        • CAD_codingC Offline
          CAD_codingC Offline
          CAD_coding
          wrote on last edited by
          #4

          Sorry but I am unable to implement the functionality.
          Can you please show some code?
          & what is anchored link that is mentioned in the documentation & how do I set it?

          1 Reply Last reply
          0
          • P Offline
            P Offline
            prady_80
            wrote on last edited by
            #5

            See the Qt docs for SetOpenExternalLinks under QLabel class, for some sample you can use the following link "this":http://www.qtcentre.org/threads/4968-QLabel-links
            QDeskTopServices::OpenURL also takes paths to local folders, therefore it can open local folders as well. The URL should however be file:/// . Ref docs of QURL class.
            HTH.

            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