Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qt Buttons: How to give button properties to an image.
QtWS25 Last Chance

Qt Buttons: How to give button properties to an image.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 994 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.
  • R Offline
    R Offline
    Ronak5
    wrote on last edited by
    #1

    Hello,

    I intend to give button properties like clicked, released etc to some images so it behaves like buttons.
    I see many types of button widgets. Could you please help in suggestion if there's any specific widget which i can link to my images to have button properties.?
    Also, can it be done in both qml and c++?

    Thanks in advance.

    J.HilkJ 1 Reply Last reply
    0
    • R Ronak5

      Hello,

      I intend to give button properties like clicked, released etc to some images so it behaves like buttons.
      I see many types of button widgets. Could you please help in suggestion if there's any specific widget which i can link to my images to have button properties.?
      Also, can it be done in both qml and c++?

      Thanks in advance.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @Ronak5

      yes there is, for qml and widgets, for both cases there are multiple ways to do it.

      I'll list the easiest method for both

      QML: Make your own Item/QMl File containing an Image and a MouseArea object -> done
      QWidget: Subclass QLabel, and overrite mouse events -> implement logic for when to emit clicked, released and pressed.
      Even so its far from perfect, the wiki article should help: https://wiki.qt.io/Clickable_QLabel


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      R 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        hi @Ronak5

        yes there is, for qml and widgets, for both cases there are multiple ways to do it.

        I'll list the easiest method for both

        QML: Make your own Item/QMl File containing an Image and a MouseArea object -> done
        QWidget: Subclass QLabel, and overrite mouse events -> implement logic for when to emit clicked, released and pressed.
        Even so its far from perfect, the wiki article should help: https://wiki.qt.io/Clickable_QLabel

        R Offline
        R Offline
        Ronak5
        wrote on last edited by
        #3

        @J.Hilk Thanks a lot mate. That is very precise and helpful.

        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