Results 1 to 6 of 6

Thread: Remove a single arrow in a QSpinBox

  1. #1
    Join Date
    Dec 2012
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Remove a single arrow in a QSpinBox

    I develop for Qt 4.8 and I'd like to have a QSpinBox (actually QTimeEdit but I don't think it's a big difference) with a single downwards arrow in the right-middle part.
    I tried using stylesheets but I've run into some problems.
    When I write
    Qt Code:
    1. QTimeEdit::up-arrow {width: 0;}
    To copy to clipboard, switch view to plain text mode 
    I get a square featureless button above the downward arrow. If I try to remove it by adding
    Qt Code:
    1. QTimeEdit::up-button {width: 0;}
    To copy to clipboard, switch view to plain text mode 
    the button above disappears but the downward arrow turns into a rectangular button. Other manipulations with stylesheets have failed to provide anything better.
    Is there a way to solve my problem?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,776
    Thanks
    262
    Thanked 773 Times in 763 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Remove a single arrow in a QSpinBox

    Seriously? You want to implement a spin box that can move only in one direction? What if the user clicks one time too many? There's no way to say "oops, I need to go back one click".

    It should seem obvious why you can't accomplish what you are trying to do with style sheets.

  3. #3
    Join Date
    Dec 2012
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove a single arrow in a QSpinBox

    Well, first of all, there is a way - either by pressing up on the keyboard or scrolling the mouse wheel.

    Second, I don't want to move at all. Pressing the arrow would summon a widget to set the time in TimeEdit (something like calendar widget in the DateEdit). Basically it would be just a decoration on the widget that is convenient to store the data I want.

    And thirdly. I can have a QSpinBox with a single down-button by using stylesheets and it would work fine. The problem is that the down-button is ugly and I want a prettier down-arrow that disappears the moment I use the word "button" in my stylesheet. You can try it yourself by using the following code

    Qt Code:
    1. setStyleSheet("QTimeEdit::up-arrow {width: 0;} QTimeEdit::up-button {width: 0;}QTimeEdit::down-button {width: 16px; subcontrol-origin: border; subcontrol-position: center right;}");
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Remove a single arrow in a QSpinBox

    That sounds more like you want a button alongside the spinbox and not show any of the spinbox's buttons.

    Cheers,
    _

  5. #5
    Join Date
    Dec 2012
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Remove a single arrow in a QSpinBox

    That is also a possible solution. However I want hte button to look like the calendar arrow in QDateEdit as much as possible to maintain stylistic integrity and I couln't find a way to make QPushButton work this way. So I tried an approached that lookes like it could have better results.

    I there is a way to make QPushButtol look like native downarrow that'd be greatly appreciated

  6. #6
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    456
    Thanks
    10
    Thanked 61 Times in 59 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Remove a single arrow in a QSpinBox

    Hi, you can try QStyle::drawPrimitive with QStyle::PE_IndicatorArrowUp or QStyle::PE_IndicatorArrowDown to draw the arrow.

    Ginsengelf

  7. The following user says thank you to Ginsengelf for this useful post:

    WereWind (1st April 2016)

Similar Threads

  1. arrow buttons
    By madhukumar in forum Qt Programming
    Replies: 1
    Last Post: 28th January 2014, 19:13
  2. Removing down-arrow
    By zgulser in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2009, 09:55
  3. QComboBox: remove drop Down Arrow
    By GuS in forum Qt Programming
    Replies: 2
    Last Post: 30th May 2008, 05:05
  4. Remove QSpinbox up/down arrows
    By SailinShoes in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2008, 21:40
  5. arrow button
    By boss_bhat in forum Qt Programming
    Replies: 3
    Last Post: 5th June 2006, 13:16

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.