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 Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 855 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.
  • T Offline
    T Offline
    turbedi
    wrote on 28 Apr 2016, 22:42 last edited by
    #1

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

    T 1 Reply Last reply 29 Apr 2016, 08:12
    0
    • T turbedi
      28 Apr 2016, 22:42

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

      T Offline
      T Offline
      the_
      wrote on 29 Apr 2016, 08:12 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

      1/2

      28 Apr 2016, 22:42

      • Login

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