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. Qlabel hyperlink not working

Qlabel hyperlink not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 726 Views
  • 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.
  • L Offline
    L Offline
    LT-K101
    wrote on last edited by
    #1

    I want to create a link to open another page, I tried this from the documentation i saw online but its not working. Any help.

    
            self.ui.label_5.linkActivated.connect(self.linkClicked)
           
    
        def linkClicked(self):
            self.ui.stackedWidget.setCurrentWidget(self.ui.page)
    
    JonBJ 1 Reply Last reply
    0
    • L LT-K101

      I want to create a link to open another page, I tried this from the documentation i saw online but its not working. Any help.

      
              self.ui.label_5.linkActivated.connect(self.linkClicked)
             
      
          def linkClicked(self):
              self.ui.stackedWidget.setCurrentWidget(self.ui.page)
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @LT-K101
      Put a print() inside linkClicked(). If it does not hit it you have a signal/slot problem. If it does then it is executing the stackedWidget.setCurrentWidget() and you need to discover what that is doing/why it does not do what you want (e.g. what is in self.ui.page, and is that a widget which is in stackedWidget?).

      L 1 Reply Last reply
      0
      • JonBJ JonB

        @LT-K101
        Put a print() inside linkClicked(). If it does not hit it you have a signal/slot problem. If it does then it is executing the stackedWidget.setCurrentWidget() and you need to discover what that is doing/why it does not do what you want (e.g. what is in self.ui.page, and is that a widget which is in stackedWidget?).

        L Offline
        L Offline
        LT-K101
        wrote on last edited by LT-K101
        #3

        @JonB Thanks for your reply, I have print() inside the linkClicked() and also set self.label_5.setOpenExternalLinks(True) but nothing happens. The self.ui.page is a widget in the stackedwidget, which i want the Qlabel to point to when i click on the label. It's kind of strange or is there another Qlabel signal/slot that can achieve this task?

        JonBJ 1 Reply Last reply
        0
        • L LT-K101

          @JonB Thanks for your reply, I have print() inside the linkClicked() and also set self.label_5.setOpenExternalLinks(True) but nothing happens. The self.ui.page is a widget in the stackedwidget, which i want the Qlabel to point to when i click on the label. It's kind of strange or is there another Qlabel signal/slot that can achieve this task?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @LT-K101
          Put in a print() to make 100% sure the linkActivated.connect(self.linkClicked) statement is actually executed. Make sure you are clicking label_5. You could try the linkHovered signal to see if you get that (note that per a bug report this is only emitted a single time for any given link, but that should be enough to verify).

          Ah, stop! The Qt docs don't make this clear at all, but it looks like whether it is emitted or not depends on what you put in the QLabel. You have to make it be an HTML link. See e.g. https://www.qtcentre.org/threads/20568-linkActivated-signal-in-QLabel

          linkActivated is emitted if you click a HTML link (a). And since you set the text 'label' the signal newer will get emitted.

          1 Reply Last reply
          1

          • Login

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