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. how can i know whether i click in the region of the UpDownArrow buttons of QDoubleSpinbox or the edit region of the rest area of QDoubleSpinbox ?
Forum Updated to NodeBB v4.3 + New Features

how can i know whether i click in the region of the UpDownArrow buttons of QDoubleSpinbox or the edit region of the rest area of QDoubleSpinbox ?

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

    how can i know whether i click in the region of the UpDownArrow buttons of QDoubleSpinbox or the edit region of the rest area of QDoubleSpinbox ?

    raven-worxR 1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi,
      please tell what you want to achieve to prevent an x-y problem.
      -Michael.

      1 Reply Last reply
      1
      • O opengpu2

        how can i know whether i click in the region of the UpDownArrow buttons of QDoubleSpinbox or the edit region of the rest area of QDoubleSpinbox ?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #3

        @opengpu2

        void MyDoubleSpinBox::mousePressEvent(QMouseEvent* event)
        {
            QDoubleSpinBox::mousePressEvent(event);
        
            QStyleOptionSpinBox opt;
            this->initStyleOption(&opt);
            const QStyle* style = this->style();
            const QPoint pos = event->pos();
         
            if( style->subControlRect(QStyle::CC_SpinBox,&opt,QStyle::SC_SpinBoxUp).contains(pos) )
                //upButton pressed
            else if( style->subControlRect(QStyle::CC_SpinBox,&opt,QStyle::SC_SpinBoxDown).contains(pos) )
                // downButton pressed
            else if( style->subControlRect(QStyle::CC_SpinBox,&opt,QStyle::SC_SpinBoxEditField).contains(pos) )
                // editfield pressed
        }
        

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2

        • Login

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