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. Open a link when clicking on a QLabel that contains a QPixmap
Forum Update on Monday, May 27th 2025

Open a link when clicking on a QLabel that contains a QPixmap

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 849 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.
  • turbediT Offline
    turbediT Offline
    turbedi
    wrote on last edited by
    #1

    Is there a simple way to open a link when the QLabel is clicked?

    the_T 1 Reply Last reply
    0
    • turbediT turbedi

      Is there a simple way to open a link when the QLabel is clicked?

      the_T Offline
      the_T Offline
      the_
      wrote on last edited by
      #2

      @turbedi

      To handle a Click on a QLabel you need to install an eventFilter.

      For example

      void MyClass::MyClass (QWidget *parent) {
        //...
        //QLabel *mylabel; can be found in the header file 
        mylabel = new QLabel;
        mylabel->installEventFilter(this);
        //...
      }
      
      bool MyClass::eventFilter(QObject *object, QEvent *event) {
        if(object == mylabel && event->type() == QEvent::MouseButtonPress) {
          //do something
        }
        return QObject::eventFilter(object, event);
      }
      

      What is done in the eventFilter depends on how you want open the link.

      -- No support in PM --

      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