Results 1 to 5 of 5

Thread: QSpinBox Right-Click

  1. #1
    Join Date
    Sep 2008
    Location
    St. Louis, MO
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QSpinBox Right-Click

    I have a QSpinBox in the cell of a QTableWidget. When I right-click in the QSpinBox I popup a context menu associated with the table. The problem is the QSpinBox also signals editingFinished whenever it's right-clicked, even if successive right-clicks occur without leaving the spin box. Is there a way to disable this behavior such that I only see editingFinished when enter is pressed or the spin box loses focus?

  2. #2
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSpinBox Right-Click

    Can you override the QSpinBox's editingFinished function and just ignore the event so it will be passed up to its parent, assuming the table is the parent. You might also have to capture the keyPressEvent to see if Enter was pressed and the focusOutEvent for losing focus. Hope this helps.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSpinBox Right-Click

    editingFinished() is a signal, so there is no practical way of overriding it.

  4. #4
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSpinBox Right-Click

    Sorry I misread his post. He could just connect this signal to a slot and ignore it, right?

  5. #5
    Join Date
    Sep 2008
    Location
    St. Louis, MO
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QSpinBox Right-Click

    I am connected to editingFinished, since I want to do something when enter is pressed. In order to handle the SIGNAL as you suggest, I would need to know if it was triggered by a right-click. I considered setting a flag when the contextMenuEvent is called, but I wasn't sure the order (contextMenuEvent vs. editingFinished) could be guaranteed.

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 15:12
  2. Right click list - some advice ?
    By aurelius in forum Qt Programming
    Replies: 5
    Last Post: 27th January 2009, 08:04
  3. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 05:32
  4. QSpinBox with checkbox
    By :db:sStrong in forum Qt Programming
    Replies: 4
    Last Post: 17th January 2007, 14:22
  5. Replies: 5
    Last Post: 12th January 2006, 16:40

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.