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. Widgets and mouse events

Widgets and mouse events

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 817 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.
  • M Offline
    M Offline
    mohamaddanesh44
    wrote on last edited by
    #1

    hi
    i need a method that give me some info about the widgets on frames sth. that works with mouse here is a part of my code but i dont know what to write in "if" statements

    void my_qlabel::mousePressEvent(QMouseEvent *ev)
    {
    emit mouse_pressed();
    if()
    {
    //change button background
    }
    else if()
    {
    //change label color
    }
    else if()
    {
    //change textline color
    }
    }

    thank for your help

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vittalonline
      wrote on last edited by
      #2

      if(ev->button() == Qt::LeftButton)
      {
      //...
      }

      1 Reply Last reply
      0
      • JeroentjehomeJ Offline
        JeroentjehomeJ Offline
        Jeroentjehome
        wrote on last edited by
        #3

        What Vittal points out is that the QMouseEvent has a list of all available options that could cause the event to be triggered. In the Qt-enum list the normal ones are defined. So, compare the event with the one you need e.g. Qt::LeftButton and so on.
        Greetz.

        Greetz, Jeroen

        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