How to change scroll bar margin in QListWidget - c++

I need that scroll bar in QListWidget have
margin = 6;

you should use a stylesheet, for example look at this :
QScrollBar:horizontal {
background: transparent;
height: 10px;
margin: 0;
}
QScrollBar:vertical {
background: transparent;
width: 10px;
margin: 0;
}
QScrollBar::handle:horizontal {
background: #374146;
min-width: 16px;
border-radius: 5px;
}
QScrollBar::handle:vertical {
background: #374146;
min-height: 16px;
border-radius: 5px;
}
QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal,
QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal,
QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {
border: none;
background: none;
}
QListWidget QScrollBar::handle:horizontal {
background-color:rgb(0, 170, 171);
}
QListWidget QScrollBar::handle:vertical {
background-color:rgb(0, 170, 171);
margin:2;
}
output
I set margin 2, margin 6 looks like this

Related

Making Bootstrap's modal-fullscreen not quite fullscreen

I needed a way to create fullscreen Bootstrap modals that weren't 'fully' fullscreen, as I felt that this may create the impression of the site having navigated to a new page. The solution seemed to be to rework the existing modal-fullscreen to pull it in a bit at the edges. I couldn't find an existing solution for this.
I had a go at custom CSS for this. Not sure how robust it is but I didn't change a lot from modal-fullscreen.
.modal-almost-fullscreen {
width: 99vw;
max-width: none;
height: 99%;
margin-top: 2px;
margin-bottom: 2px;
}
.modal-almost-fullscreen .modal-content {
height: 99%;
border: 0;
}
.modal-almost-fullscreen .modal-header,
.modal-almost-fullscreen .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen .modal-body {
overflow-y: auto;
}
#media (max-width: 575.99px) {
.modal-almost-fullscreen-sm-down {
width: 99vw;
max-width: none;
height: 99%;
margin: 0;
}
.modal-almost-fullscreen-sm-down .modal-content {
height: 99%;
border: 0;
border-radius: 0;
}
.modal-almost-fullscreen-sm-down .modal-header,
.modal-almost-fullscreen-sm-down .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen-sm-down .modal-body {
overflow-y: auto;
}
}
#media (max-width: 767.99px) {
.modal-almost-fullscreen-md-down {
width: 99vw;
max-width: none;
height: 99%;
margin: 0;
}
.modal-almost-fullscreen-md-down .modal-content {
height: 99%;
border: 0;
border-radius: 0;
}
.modal-almost-fullscreen-md-down .modal-header,
.modal-almost-fullscreen-md-down .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen-md-down .modal-body {
overflow-y: auto;
}
}
#media (max-width: 991.99px) {
.modal-almost-fullscreen-lg-down {
width: 99vw;
max-width: none;
height: 99%;
margin: 0;
}
.modal-almost-fullscreen-lg-down .modal-content {
height: 99%;
border: 0;
border-radius: 0;
}
.modal-almost-fullscreen-lg-down .modal-header,
.modal-almost-fullscreen-lg-down .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen-lg-down .modal-body {
overflow-y: auto;
}
}
#media (max-width: 1199.99px) {
.modal-almost-fullscreen-xl-down {
width: 99vw;
max-width: none;
height: 99%;
margin: 0;
}
.modal-almost-fullscreen-xl-down .modal-content {
height: 99%;
border: 0;
border-radius: 0;
}
.modal-almost-fullscreen-xl-down .modal-header,
.modal-almost-fullscreen-xl-down .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen-xl-down .modal-body {
overflow-y: auto;
}
}
#media (max-width: 1399.99px) {
.modal-almost-fullscreen-xxl-down {
width: 99vw;
max-width: none;
height: 99%;
margin: 0;
}
.modal-almost-fullscreen-xxl-down .modal-content {
height: 99%;
border: 0;
border-radius: 0;
}
.modal-almost-fullscreen-xxl-down .modal-header,
.modal-almost-fullscreen-xxl-down .modal-footer {
border-radius: 0;
}
.modal-almost-fullscreen-xxl-down .modal-body {
overflow-y: auto;
}
}
JSFiddle:
https://jsfiddle.net/valoukh/e2karuxf/

QSlider handle ignores border radius when height is reduced

I am trying to create a gui application to control the volume level of my machine using Qt5 and C++.
This is what I kind of want to achieve.
So, I created the basic layouts and added the QSlider, and then used the following stylesheet to style it:
QSlider::groove:horizontal
{
height: 16px;
background: yellow;
margin: 2px;
}
QSlider::handle:horizontal
{
background: blue;
width: 16px;
height: 16px;
margin: -5px 6px -5px 6px;
border-radius:11px;
border: 3px solid #ffffff;
}
I got the following result:
First the handle is an eclipse, and not a circle. But I wanted to reduce the height of the groove, so I modified the above stylesheet:
QSlider::groove:horizontal
{
height: 10px; // modified here
background: yellow;
margin: 2px;
}
QSlider::handle:horizontal
{
background: blue;
width: 16px;
height: 16px;
margin: -5px 6px -5px 6px;
border-radius:11px;
border: 3px solid #ffffff;
}
And now, the handle of the slider became a rectangle.
Can anyone please answer what's causing it to behave like this, or point me to some docs.
your border-radius should be proportional to the length and width to become a circle.
Try this style :
QSlider::groove:horizontal {
border-radius: 1px;
height: 3px;
margin: 0px;
background-color: rgb(52, 59, 72);
}
QSlider::groove:horizontal:hover {
background-color: rgb(55, 62, 76);
}
QSlider::handle:horizontal {
background-color: rgb(85, 170, 255);
border: none;
height: 40px;
width: 40px;
margin: -20px 0;
border-radius: 20px;
padding: -20px 0px;
}
QSlider::handle:horizontal:hover {
background-color: rgb(155, 180, 255);
}
QSlider::handle:horizontal:pressed {
background-color: rgb(65, 255, 195);
}
And This is for your style (I change margin and padding)
QSlider::groove:horizontal
{
height: 16px;
background: yellow;
margin: 2px;
}
QSlider::handle:horizontal
{
background: blue;
width: 16px;
height: 16px;
margin: -4px 0;
padding: -4px 0px;
border-radius:11px;
border: 3px solid #ffffff;
}

QComboBox ListView is occuping combobox frame

the comboBox contains two entries and , when the combobox is clicked, the listview occupies the frame of combobox. I want the list view just below the combobox. stylesheet is as shown below:
QComboBox {
border: 1px solid #8F9EAB;
border-radius: 3px;
font: 16pt "Arial";
min-width: 6em;
color: #1B3067;
background-color: rgb(255, 255, 255);
padding-left:10px;
}
QComboBox:pressed
{
border: 1px solid #1562AD;
color: rgb(255, 255, 255);
background-color: #87A6D5;
}
QComboBox:disabled
{
border: 1px solid #BFBFBF;
color: #BFBFBF;
background-color: rgb(255, 255, 255);
}
QComboBox::down-arrow
{
background-image: url(:/Images/data/img/Images/DOWN_enabled.png);
height: 7px;
width : 13px;
}
QComboBox::drop-down
{
subcontrol-position: top right;
width: 40px;
color: white;
border-left-width: 0px;
border-left-color: #8F9EAB;
border-left-style: solid;
border-top-right-radius: 3px;
border-bottom-right-radius: 3px;
}
QComboBox QListView
{
font: 16pt "Arial";
color: rgb(80, 80, 80);
}
QComboBox QAbstractItemView::item
{
border-bottom: 5px solid white; margin:3px;
}
The position of the view() can not be handled with Qt Style Sheet, you must create a class that inherits from QComboBox and overwrite the showPopup() method as shown below.
class ComboBox: public QComboBox{
public:
using QComboBox::QComboBox;
public:
void showPopup(){
QComboBox::showPopup();
QPoint pos = mapToGlobal(QPoint(0, height()));
view()->parentWidget()->move(pos);
}
};

Changing QWidget object scope changes the CSS

Consider this two parts of code
NotifWidget* notifWidget_ = new NotifWidget();
notifWidget_->show();
notifWidget_->move(computePosition(notifWidget_));
notifWidget_->show();
notifWidget_->move(computePosition(notifWidget_));
In first case the NotifWidget (which is inherited from QFrame) the notifWidget_ object is local object and the corresponding widget is show like this
In the second case the notifWidget_ object is the class member and and here is the image for that case
Both widgets have same CSS style sheet and same objectName. Does anyone know what's the problem for the second case? Why in second case the inner widgets are overlapped?
update
including css(if any)
QWidget#NotifWidget_actions
{
border:0px solid;
}
QWidget#AccessGiven, QWidget#AccessGiven[onhover="false"]
{
background: white;
}
QWidget#AccessGiven[onhover="true"]
{
background: #f2f2f2;
}
QLabel#AccessGiven_icon, QLabel#AccessGiven_message, QLabel#AccessGiven_icon[onhover="false"], QLabel#AccessGiven_message[onhover="false"]
{
background: white;
padding-bottom: 0px;
qproperty-wordWrap: true;
max-height: 48px;
min-height: 48px;
}
QLabel#AccessGiven_message
{
font: 12px;
max-width: 200px;
min-width: 200px;
}
QLabel#AccessGiven_icon
{
max-width: 64px;
min-width: 64px;
}
QLabel#AccessGiven_icon[onhover="true"], QLabel#AccessGiven_message[onhover="true"]
{
background: #f2f2f2;
}
QPushButton#AccessGiven_action, QPushButton#AccessGiven_action[onhover="true"]
{
font: 12px;
color: rgba( 35, 35, 35, 0% );
padding-bottom: 0px;
background-color: rgba( 35, 35, 35, 0% );
margin-left: 0px;
}
QPushButton#AccessGiven_action[onhover="true"]
{
color: rgba( 35, 35, 35, 50% );
}
QPushButton#AccessGiven_action:hover
{
background: rgba( 35, 35, 35, 20% );
}
QPushButton#AccessGiven_action:pressed
{
background: rgba( 35, 35, 35, 10% );
padding-bottom: 2px;
}
QPushButton#NotifWidget_settings
{
background-image: url(./media/settings.png);
height: 24px;
width: 24px;
background-repeat: no-repeat;
background-position: center center;
border: 0px;
}
QPushButton#NotifWidget_settings:hover
{
background-color: lightgray;
}
QPushButton#NotifWidget_settings:pressed
{
background-color: silver;
}
QPushButton#NotifWidget_help
{
background-image: url(./media/help.png);
height: 24px;
width: 24px;
background-repeat: no-repeat;
background-position: center center;
border: 0px;
}
QPushButton#NotifWidget_help:hover
{
background-color: lightgray;
}
QPushButton#NotifWidget_help:pressed
{
background-color: silver;
}
QPushButton#NotifWidget_toWeb
{
height: 24px;
width: 24px;
background-image: url(./media/web.png);
background-repeat: no-repeat;
background-position: center center;;
border: 0px light ;
}
QPushButton#NotifWidget_toWeb:hover
{
background-color: lightgray;
}
QPushButton#NotifWidget_toWeb:pressed
{
background-color: silver;
}
QPushButton#NotifWidget_exit
{
height: 14;
padding:2px;
margin-left:5px;
background-color: rgb(255,0,0, 0%);
border: 1px light ;
}
QPushButton#NotifWidget_exit:hover
{
background-color: rgb(255,0,0, 25%);
}
QPushButton#NotifWidget_exit:pressed
{
background-color: rgb(255,0,0, 35%);
}
QScrollArea#NotifWidget_scrollArea
{
/* background: transparent;
border: 0px solid;*/
}
QFrame#NotifWidget
{
background-color: #F5F5F5;
/*min-width: 345;
max-width: 345;
min-height: 400;*/
border: 1px solid rgb(37, 76, 241);
}

Is it possible to set transition delay on :after?

How to set transition delay on li:after so that it aligns with transition for li:hover? Seems like it doesn't work when transition: all 0.3s; is set, because it appears instantly.
Here is the Fiddle
Maybe if you do something like this, where you first set up the :after and then show it on :hover
body {
background-color: #f01;
}
ul {
background-color: #fff;
}
li {
position: relative;
list-style-type: none;
display: inline;
line-height: 2em;
padding: 5px;
transition: all 1s;
}
li:hover {
background-color: #414C52;
transition: all 1s;
}
li:after {
top: 25px;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(136, 183, 213, 0);
border-top-color: #414C52;
margin-left: -10px;
transition: all 1s;
border-width: 10px;
opacity: 0;
}
li:hover:after {
opacity: 1;
transition: all 1s;
}
a {
padding: 12px 10px color: #333;
}
<ul class="nav navbar-nav">
<li>asdfasdf</li>
<li class="active">ffffft</li>
</ul>
yes, it should do it but you need an inital li:after before your li:hover:after