How to Remove Delay on Css3 Slide out transition which uses max-height transition - css-transitions

I'm having an issue with a transition I'm using to slide a panel in and out.
Please take a look at the following jsbin http://jsbin.com/uvejuj/1/
Notice that when i click the toggle button the first time the transition occurs immediately.
However if i click the button again to close then the transition delays the amount of time of the transition before it executes.
What is causing the delay on close out and how can i get rid of it?
Thanks

Fixed JS Bin
Fix delay solution:
Put cubic-bezier(0, 1, 0, 1) transition function for element.
.text {
overflow: hidden;
max-height: 0;
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
&.full {
max-height: 1000px;
transition: max-height 1s ease-in-out;
}

It's because you're animating between 0 and 1000px max height but your content is only about 120px high. The delay is the animation happening on the 880 pixels that you can't see.
Either set max-height to the known height of your content (if you know it - example: http://jsbin.com/onihik/1/) or try a different method. Maybe something like https://stackoverflow.com/a/6486082/2619379

I fixed it in my case by using normal transition for opening (from max-height 0px to max-height 500px) BUT by using an animation when closing, starting from max-height 50vh.
This way the delay is not from shrinking from 5000px to the actual height of your content.
The only delay that can appear now is if your content is less than 50% of your screen height, but that works buttersmooth in my cases.
Here's my magic (scss format):
.slide-open{
max-height: 0;
overflow: hidden;
&:not(.open){
animation-name: shrink;
animation-duration: .3s;
}
&.open{
max-height: 5000px;
transition: max-height .9s ease-in-out;
}
}
#keyframes shrink {
0% { max-height: 50vh; }
100% { max-height: 0; }
}

Related

How to set QProgressBar stylesheet dynamically?

I'm trying to make a progress bar that can dynamically change part of it's color depending on a slider's value. The closest I can get to that right now is by using:
bar->setStyleSheet(QString("QProgressBar::chunk:vertical {background: qlineargradient(x1:0, y1:0, x2: 0, y2: 1, stop:0 red, stop:0.5 green); border-radius: 9px;}")
+QString("QProgressBar::vertical {border: 1px solid #b4adad; border-radius: 9px; background: #2f2828; padding: 0px; text-align: left; margin-right: 4ex;}"));
I have tried setting the second stop point to slider->value() which takes away the whole style sheet leaving me with a blank progress bar.
I have tried just using CSS code which also takes away the style sheet:
{background: linear-gradient(to bottom, white 0%, blue 25%, blue 100%); border-radius: 9px;}"
I'm confused because I can use CSS to set the background but I can't get it to work unless I use qlineargradient, why is this? What needs to be done in order to implement CSS in a Qt stylesheet without restriction?
Is it possible to set the value of a stop point to the changing value of a slider?
I also attempted using the setStyleSheet function within an if statement so that the stylesheet itself will change depending on the value of the progress bar:
if (bar->value()<slider->value()) {
however this doesn't dynamically change the stylesheet. It seems as though it runs the if statement one time prior to opening the app. Does QT run a while loop that runs through the code continuously while the app is open or am I mistaken?
From https://doc.qt.io/qt-5/qprogressbar.html#valueChanged, there is a signal void QProgressBar::valueChanged(int value) that you can connect to a slot and make the change you want for the QProgressBar sylesheet, for example :
void MainWindow::on_progressBar_valueChanged(int value)
{
if (value >= 0 && value < 50)
ui->progressBar->setStyleSheet("border: 2px solid grey; border-radius: 5px; text-align: center;");
else if (value >= 50 && value < 75)
ui->progressBar->setStyleSheet("background-color: #05B8CC; width: 20px;");
// and so on ...
}

Why do my QListWidgetItems break to the next line before reaching the edge of the window?

I'm creating an image grid in Qt as seen in these screenshots:
One row
Row break
The problem occurs while resizing the window. The last image breaks onto the next row before it touches the edge of the window. This is even more noticeable when the items are larger. Is it possible to change some padding/marging/spacing to allow the grid to bump into the edge, then break to the next row?
I've tried using this, but it doesn't work:
#listWidget{
background-color: green;
padding-top: 5px;
}
#listWidget::item{
background-color: red;
margin: 0px;
padding: 0;
}
As a side question, I am able to remove the item padding, as seen with the red background, by using this stylesheet:
#listWidget::item{
padding: -1px -3px -4px -4px;
}
Is there a better way to remove the padding from individual items so they are right next to each other? Why doesn't margin: 0; padding: 0; work?

border and text qss settings at QTableView

Here's I am trying to do that:
but I set that stylesheet in my QTableView:
QTableView {
gridline-color: black;
background-color: transparent;
}
QHeaderView {background-color: transparent;
}
QHeaderView::section{
border-style: none;
border-bottom: 1px solid rgb(0,0,0);
background-color: transparent;
margin-bottom:5px;
margin-top:5px;
}
QTableView QTableCornerButton::section {
bottom-style:none;
border-bottom: 1px solid rgb(0,0,0);
}
Result is this:
I can handle with size problem for future but there is two main problem over here:
1.Column text between border there isnt any space, I did margin-top:5px; and margin-bottom:5px; but it changed for all QHeaderView not only QHeaderView's Text. (Solution is use padding instead of margin)
2.Every row has a right ,left even top border. I dont want that.
I tried this:
QTableView QTableCornerButton::section {
border-style:none;
border-bottom: 1px solid rgb(0,0,0);
}
Unfortunately there is a problem at QTableCornerButton:section it doesn't work...
Thank you for any helping
Note : I haven't verified, these are just suggestions to try, please upload the output if needed
1 - What do you mean by "it changed for all QHeaderView not only QHeaderView's Text"?
Maybe you expected to set margin only to the headerview's content (text) : in that case use the padding not margin.
QHeaderView::section{
/* your style */
padding-bottom:5px;
padding-top:5px;
}
2 - Every row has a right ,left even top border. I dont want that.
QTableView {
/* sone additional style */
gridline-color: cyan
background-color: cyan
}
QTableView::item
{
border-style: none;
border-bottom: 1px solid rgb(0,0,0);
}
I would try to use the border-style (set to none) as you did in QHeaderView's style.
Edit : You certainly must disable the showgrid's option of your QTableView by code to make it a working solution
tableView.setShowGrid(false);

Foundation 5 orbit bullets

I would like to move bullet navigation on the slider,so it would be somewhere in the middle. But when i do this and click on the other slide the bullets disappear. Any ideas how to fix this?
You need to override some of the orbit bullets CSS rules, like:
.orbit-bullets {
position: absolute; // instaed of relative
top: 100px; // where you want it
z-index: 1000; // > 10 will probably work
}

Change the color of a QProgressBar

I am running ubuntu 11.04. This is what my progress bars look like:
I am showing the progress bars in a batch processing window (one per batch item) and would like to use them as a status indicator (green while all is going well, red in case of errors, ...).
I have tried several suggestions, including the ones made to this almost identical question. Unfortunately, I couldn't make it work and the documentation on customizing QProgressBars doesn't help me either, so I would be very grateful for any suggestions as to what I'm doing wrong.
I have subclassed the QProgressBar as suggested and have tried using stylesheets as well as the palette (not at the same time but as alternatives). With stylesheets, I can't make it look anything like the regular progress bars. Changing the color is really all I want to do, so I figured it should be much easier to do that by use of a palette instead of a stylesheet, but with the palette nothing happens at all.
Here is one of the versions I've tried for the palette:
#include "myprogressbar.h"
#include <QtGui/QPalette>
MyProgressBar::MyProgressBar(QWidget *parent) :
QProgressBar(parent)
{}
void MyProgressBar::onProgress(int value, int maximum, QString phase)
{
setMaximum(maximum);
setValue(value);
setFormat(phase);
QPalette p = this->palette();
p.setColor(QPalette::Highlight, QColor(Qt::green));
this->setPalette(p);
}
...
I also tried the version suggested here, but that didn't help either.
It tried this :
QProgressBar {
border: 2px solid grey;
border-radius: 5px;
background-color: #FF0000;
}
QProgressBar::chunk {
background-color: #05B8CC;
width: 20px;
}
as styleSheet for the progressBar and I got this
so it is easy to change the background of the bar to the color you want and you can display a text by yourself with setFormat(). Is it working for you?
Using the "Highlight" color role does the trick in my case (using Plastique style).
QPalette p = palette();
p.setColor(QPalette::Highlight, Qt::green);
setPalette(p);
I had this problem too, but I find a way, with the help of this site:
http://thesmithfam.org/blog/2009/10/13/cool-qprogressbar-stylesheet/
but I just wanted to change the color and not the progressbar itself. so I got rid of the first line, and change the second one a little bit.
Finally I got what I wanted.
First do this:
QString danger = "QProgressBar::chunk {background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 #FF0350,stop: 0.4999 #FF0020,stop: 0.5 #FF0019,stop: 1 #FF0000 );border-bottom-right-radius: 5px;border-bottom-left-radius: 5px;border: .px solid black;}";
QString safe= "QProgressBar::chunk {background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0,stop: 0 #78d,stop: 0.4999 #46a,stop: 0.5 #45a,stop: 1 #238 );border-bottom-right-radius: 7px;border-bottom-left-radius: 7px;border: 1px solid black;}";
Now all you have to do is:
if(ui->progressbar->value()<80)
ui->progressbar->setStyleSheet(danger);
else
ui->progressbar->setStyleSheet(safe);