How to set QAction to have transparent background inside QToolBar - qt

After creating a QToolBar I'm adding QAction to it with icons, but when I set QToolBar StyleSheet QAction will have a white background instead of a transparent one like in the photo below
code:
QToolBar *toolBarFile = addToolBar("File");
toolBarFile->setMinimumWidth(70);
this->addToolBar(Qt::LeftToolBarArea, toolBarFile);
toolBarFile->setMovable(false);
toolBarFile->setStyleSheet("*{border: none;}"
"QToolBar{background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #f2f2f2, stop: 0.8 #f2f2f2, stop: 1 #999999);}");
QAction* ActionUniversal = new QAction(QIcon(":/DownArrow.png"), "&Open", this);
toolBarFile->addAction(ActionUniversal);
ActionUniversal = new QAction(QIcon(":/DownArrow.png"), "&Open", this);
toolBarFile->addAction(ActionUniversal);
ActionUniversal = new QAction(QIcon(":/DownArrow.png"), "&Open", this);
toolBarFile->addAction(ActionUniversal);
ActionUniversal = new QAction(QIcon(":/DownArrow.png"), "&Open", this);
toolBarFile->addAction(ActionUniversal);
Another example that shows the transparency of the background of my image:
what has changed in my code:
toolBarFile->setStyleSheet("border: none;"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #f2f2f2, stop: 0.8 #f2f2f2, stop: 1 #999999);");

Try this:
toolBarFile->setStyleSheet("QToolButton{border: none; background-color: transparent;} "
"QToolBar{background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #f2f2f2, stop: 0.8 #f2f2f2, stop: 1 #999999);}");

Related

How do I create hard-stop backgrounds in SASS/SCSS?

I've created a gradient that has 11 hard stops, creating the illusion of 11 separate boxes.
As it stands now, there's a % of the width hard-coded into the linear gradient. I can't help but think there's a much more efficient way (via SCSS?) rather than coding this out as such:
.color-bar {
background: linear-gradient( to left,
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0) 9.09%,
rgba(0, 0, 0, .1) 9.09%,
rgba(0, 0, 0, .1) 18.18%,
rgba(0, 0, 0, .2) 18.18%,
rgba(0, 0, 0, .2) 27.27%,
rgba(0, 0, 0, .3) 27.27%,
rgba(0, 0, 0, .3) 36.36%,
rgba(0, 0, 0, .4) 36.36%,
rgba(0, 0, 0, .4) 45.45%,
rgba(0, 0, 0, .5) 45.45%,
rgba(0, 0, 0, .5) 54.54%,
rgba(0, 0, 0, .6) 54.54%,
rgba(0, 0, 0, .6) 63.63%,
rgba(0, 0, 0, .7) 63.63%,
rgba(0, 0, 0, .7) 72.72%,
rgba(0, 0, 0, .8) 72.72%,
rgba(0, 0, 0, .8) 81.81%,
rgba(0, 0, 0, .9) 81.81%,
rgba(0, 0, 0, 1) 90.09%,
rgba(0, 0, 0, 1) 100%);
height: 50px;
width: 550px;
}
<div class="color-bar"></div>
Here's a rough Codepen in action.
Thanks for any input you can provide.
Took me a bit of fiddling, but here it is:
#function hard-stops($direction, $from, $to, $steps) {
$output: unquote("linear-gradient(") + $direction;
#for $i from 0 through $steps {
$output: $output + ', '
+ mix($from, $to, $i*100/$steps) + ' '
+ percentage($i/($steps+1)) + ', '
+ mix($from, $to, $i*100/$steps) + ' '
+ percentage(($i+1)/($steps+1));
}
$output: $output + ')';
#return $output;
}
.color-bar {
height: 50px;
width: 550px;
background: hard-stops(to left, rgba(0,0,0,1), rgba(0,0,0,0), 10);
}
jsFiddle.
The limitation is: one needs to pass mix-able colors (black, for example, is not, no idea why - I'm not much of an expert in sass).

Does fabricjs support radial-gradient?

I'm working with Fabric to create Radial-gradient like this
It can create very easily by css. Like this
<!DOCTYPE html>
<html>
<head>
<style>
#grad1 {
width: 100px;
height: 100px;
border-radius: 50%;
background: radial-gradient(ellipse at center, #1e5799 0%,rgba(255, 255, 255, 0) 100%);
}
</style>
</head>
<body>
<h3>Radial Gradient - Evenly Spaced Color Stops</h3>
<div id="grad1"></div>
<p><strong>Note:</strong> Internet Explorer 9 and earlier versions do not support gradients.</p>
</body>
</html>
But seem fabricJS do not support it. It only support gradient from side to side (?)
Does anyone work with this before. Please give me support.
Thank you
Yes
Some example: http://jsfiddle.net/fabricjs/58y8b/
// initialize fabric canvas and assign to global windows object for debug
var canvas = window._canvas = new fabric.Canvas('c');
// Do some initializing stuff
fabric.Object.prototype.set({
transparentCorners: false,
cornerColor: 'rgba(102,153,255,0.5)',
cornerSize: 12,
padding: 5
});
// Initialze the example
var rect1 = new fabric.Rect({
left: 100,
top: 100,
width: 100,
height: 100,
fill: '#ffda4f'
});
var rect2 = new fabric.Rect({
left: 250,
top: 100,
width: 100,
height: 100,
fill: 'rgb(111,154,211)'
});
var rect3 = new fabric.Rect({
left: 400,
top: 100,
width: 100,
height: 100,
fill: 'rgb(166,111,213)'
});
var rect4 = new fabric.Rect({
left: 100,
top: 400,
width: 100,
height: 100,
fill: '#ffda4f'
});
var rect5 = new fabric.Rect({
left: 250,
top: 400,
width: 100,
height: 100,
fill: 'rgb(111,154,211)'
});
var rect6 = new fabric.Rect({
left: 400,
top: 400,
width: 100,
height: 100,
fill: 'rgb(166,111,213)'
});
canvas.add(rect1, rect2, rect3, rect4, rect5, rect6);
/**
* setGradient linear gradients example
*/
// horizontal linear gradient
rect1.setGradient('fill', {
type: 'linear',
x1: -rect1.width / 2,
y1: 0,
x2: rect1.width / 2,
y2: 0,
colorStops: {
0: '#ffe47b',
1: 'rgb(111,154,211)'
}
});
// vertical linear gradient
rect2.setGradient('fill', {
type: 'linear',
x1: 0,
y1: -rect2.height / 2,
x2: 0,
y2: rect2.height / 2,
colorStops: {
0: '#ff4040',
1: '#e6399b'
}
});
// diagonal linear gradient
rect3.setGradient('fill', {
type: 'linear',
x1: -rect3.width / 2,
y1: -rect3.height / 2,
x2: rect3.width / 2,
y2: rect3.height / 2,
colorStops: {
0: 'rgb(166,111,213)',
0.5: 'rgba(106, 72, 215, 0.5)',
1: '#200772'
}
});
/**
* setGradient radial gradients example
*/
// radial gradient
rect4.setGradient('fill', {
type: 'radial',
r1: rect4.width / 2,
r2: 10,
x1: 0,
y1: 0,
x2: 0,
y2: 0,
colorStops: {
0: '#FF4F4F',
1: 'rgb(255, 239, 64)'
}
});
// radial gradient
rect5.setGradient('fill', {
type: 'radial',
r1: rect5.width / 2,
r2: 10,
x1: 0,
y1: 0,
x2: rect4.width / 4,
y2: rect4.height / 4,
colorStops: {
0: '#ffe47b',
0.5: 'rgb(111,154,211)',
1: 'rgb(166,111,213)'
}
});
// radial gradient
rect6.setGradient('fill', {
type: 'radial',
r1: 50,
r2: 80,
x1: 45,
y1: 45,
x2: 52,
y2: 50,
colorStops: {
0: 'rgb(155, 237, 0)',
1: 'rgba(0, 164, 128,0.4)'
}
});
canvas.renderAll();
You can do it like this:
let cir = new fabric.Circle({
left: 100,
top: 100,
radius: 30,
fill: 'rgba(0, 0, 0, 0)'
})
cir.setGradient('fill', {
type: 'radial',
r1: 30,
r2: 2,
x1: 30,
y1: 30,
x2: 30,
y2: 30,
colorStops: {
1: 'rgb(113,182,203)',
0: 'rgba(0, 0, 0, 0)'
}
});
fabricCanvas.add(cir);
fabricCanvas.renderAll();
http://jsfiddle.net/Kyashar/z6428pta/

How to make checked QPushButton look the same as when it's pressed?

How to make checked QPushButton look same as when it's pressed? Like this:
This is a picture of the pressed button. What should I write in stylesheet?
"QPushButton:pressed {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #dadbde, stop: 1 #f6f7fa);}"
"QPushButton:checked {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #dadbde, stop: 1 #f6f7fa);"
"border: none;}"
I tried to write border as none, but I just got this:
And I need borders stay the same.
This is because on default QPushButton:pressed has its own border which is set natively based on your OS.
To get around this, you can set the QPushButton:pressed border to something very similar to how it looks now, then set the same border for QPushButton:checked.
It seems to me that it is a 1px wide, black, inset border, so something like this should do the trick.
"QPushButton:pressed {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #dadbde, stop: 1 #f6f7fa);"
"border: 1px inset black;}"
"QPushButton:checked {"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0 #dadbde, stop: 1 #f6f7fa);"
"border: 1px inset black;}"

How do I style a different border?

how can I style a border differently then solid/dotted etc.?
I do have a zigzag-line as a border-top and of course I can display it as a graphic-file within the background, but is there a different (more modern) way to achieve that?
I am asking this specifically for a zigzag-line for one border (border-top) AND for any other scenario, where a different looking border shall be used (rotated solid borders....)
How would I do something like this?
::before
css-shapes
still with graphic-files
It should work down to IE9
Thanks
try this codePen example:
http://codepen.io/pouretrebelle/pen/hypGk
.bordered {
background-color: #efe6ef;
position: relative;
margin: 100px auto;
height: 5em;
width: 25em;
}
.bordered:before, .bordered:after {
content: '';
position: absolute;
background-repeat: repeat;
z-index: -1;
}
.bordered:before {
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuMCIgeTE9IjAuMCIgeDI9IjEuMCIgeTI9IjEuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9Ijc1JSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9Ijc1JSIgc3RvcC1jb2xvcj0iI2I2YjVlYiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2I2YjVlYiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC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 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background: -webkit-linear-gradient(315deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background: linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(315deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background-position: 0.5em 0.5em, 0.5em 0.5em, 0 0.5em, 0 0.5em;
background-size: 1em 1em;
left: 0;
top: -1em;
height: 7em;
width: 100%;
}
.bordered:after {
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+P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RzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuMCIgeTE9IjEuMCIgeDI9IjEuMCIgeTI9IjAuMCI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9Ijc1JSIgc3RvcC1jb2xvcj0iIzAwMDAwMCIgc3RvcC1vcGFjaXR5PSIwLjAiLz48c3RvcCBvZmZzZXQ9Ijc1JSIgc3RvcC1jb2xvcj0iI2I2YjVlYiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2I2YjVlYiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
background: -moz-linear-gradient(315deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -moz-linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background: -webkit-linear-gradient(315deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), -webkit-linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background: linear-gradient(135deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(315deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(225deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb), linear-gradient(45deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0) 75%, #b6b5eb 75%, #b6b5eb);
background-position: 0.5em 0.5em, 0.5em 0em, 0.5em 0, 0.5em 0.5em;
background-size: 1em 1em;
left: -1em;
top: 0;
height: 100%;
width: 27em;
}
h1 {
text-align: center;
line-height: 2.5em;
font-size: 2em;
font-family: Quando, serif;
font-weight: normal;
position: relative;
}
<div class="bordered">
<h1>CSS Zigzag Border</h1>
</div>

writing LESS mixin for box-shadow: none

I have a problem with writing the box-shadow mixin using LESS css.
The following is the Mixin for box-shadow
.boxShadow (#x, #y, #blur, #spread: 0, #alpha) {
-webkit-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
-moz-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
}
but i can able pass parameters with no issues,
.boxShadow(0, 0, 5px, 2px, 0.2);
but how to call the same mixin for box-shadow: none
There is a way to access all the mixin arguments in one variable.
You could write your LESS mixin in this way:
.box-shadow(...)
{
-webkit-box-shadow: #arguments;
-moz-box-shadow: #arguments;
box-shadow: #arguments;
}
And use it later:
.box-shadow(0 0 5px 2px rgba(0, 0, 0, 0.2));
or
.box-shadow(none);
.boxShadow(#x, #y, #blur, #spread: 0, #alpha) {
-webkit-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
-moz-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
}
.boxShadow(none) {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
The point is that you can define mixins with the same name but different parameters in Less. Just "override" your mixin and Less will find one with the same parameter pattern.
.drop-shadow (#x: 0, #y: 1px, #blur: 2px, #spread: 0, #alpha: 0.25) {
-webkit-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
-moz-box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
box-shadow: #x #y #blur #spread rgba(0, 0, 0, #alpha);
}
.inner-shadow (#x: 0, #y: 1px, #blur: 2px, #spread: 0, #alpha: 0.25) {
-webkit-box-shadow: inset #x #y #blur #spread rgba(0, 0, 0, #alpha);
-moz-box-shadow: inset #x #y #blur #spread rgba(0, 0, 0, #alpha);
box-shadow: inset #x #y #blur #spread rgba(0, 0, 0, #alpha);
}

Resources