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. MousePressEvent get the widgetName?

MousePressEvent get the widgetName?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 828 Views 2 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.
  • GofferG Offline
    GofferG Offline
    Goffer
    wrote on last edited by Goffer
    #1

    Hello !

    Today I have implemented my own widget based on QWidget and I added a mousePressEvent so whenever I create this widget, I can click inside and trigger an event. Now I would like that when I click it returns my widgetObjectName.
    How could I do that ?

    I ve seen that maybe I could get the mouse position and then use itemAt()
    but it doesn't seem to work for QWidget...

    Any simple way of doing that ?

    Thx

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      I'm not sure to fully understand your question.
      What do you need? Inside the mousePressEvent() handler you have full access to the widget data. You can emit a signal and in the slot you can use the QObject::sender() function to have a pointer to the signal sender.

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      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