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. Adding styles to a QSpinBox

Adding styles to a QSpinBox

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 525 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.
  • M Offline
    M Offline
    maria.v
    wrote on 6 Apr 2020, 18:54 last edited by
    #1

    How do I make a qtspinbox look like this?

    Screen Shot 2020-04-06 at 15.40.46.png

    This is the best I got?

    Screen Shot 2020-04-06 at 15.52.48.png

    
    QSpinBox {
    	border-radius: 2px;
    	border: 1px solid rgba(72, 66, 66, 0.5);
    	padding: 4px;
    }
    
    QSpinBox::up-button {
    	subcontrol-position: top;
        width: 14px;
        height: 14px;
        margin-left: 8px;
    }
    
    QSpinBox::down-button {
    	subcontrol-position: bottom;
        width: 14px;
        height: 14px;
        margin-left: 8px;
    }
    
    1 Reply Last reply
    0
    • G Offline
      G Offline
      gde23
      wrote on 7 Apr 2020, 07:06 last edited by
      #2

      To get rid of the grey +/i buttons you have to set the border and backgroundcoler for the subcontrols:

      border: 0px;
      background-color: white;            
      

      However this will also remove the icon (arrow or +/-) on the subcontrol, so you have to set it yourself e.g.

      image: url(:/images/plus_icon.png);
      

      where plus_icon.png is an icon that you have added to the resources

      1 Reply Last reply
      2

      2/2

      7 Apr 2020, 07:06

      • Login

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