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. Know when the mouse is hovering over SpinBox arrow buttons?

Know when the mouse is hovering over SpinBox arrow buttons?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.2k 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.
  • D Offline
    D Offline
    DanBrakeley
    wrote on last edited by
    #1

    A spin box generally has an editable value and two buttons to step the value up and down. I would like to make a custom spin box that is aware of when the mouse clicks on the arrow buttons as opposed to in the text field. The ultimate goal is to have a spin box where you can click and drag on either arrow to advance the value up or down, depending on how far you move the mouse up/down from the point of the click.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DanBrakeley
      wrote on last edited by
      #2

      I figured out a way to do this, but it feels fragile:

      QAbstractSpinBox has an accessor to get the lineEdit control, so I just use the width of the line edit and presume that if I get a click whose x is larger than lineEdit().width(), it is over the arrows instead of over the line edit control. Not sure if I can rely on this in all styles, but for now it is at least working.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        I think QStyle should be able to tell you the rect for the buttons, actually. You might be in trouble if RTL layouts in your current approach.

        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