Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Adding styles to a QSpinBox



  • 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;
    }
    


  • 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


Log in to reply