I'm working with QT and I have a menu. I have the follwing css for the menu:
QMenu {
/* background-color: #0F7070;*/
background-color:rgb(44,63,80);
border-top: none;
border-left:none;
border-right:none;
border-bottom:4px solid rgb(44,205,112);;
color:#fff;;
}
QMenu::item {
spacing: 3px; /* spacing between menu bar items */
padding: 10px 85px 10px 20px;
background: transparent;
}
/*Does not work*/
QMenu::item:hover {
background-color: rgb(52,73,94);
border-top: none;
border-left:none;
border-bottom:none;
border-left:3px solid rgb(44,205,112);;
}
How can I set the :hover to the item? Thank you.
I had same issue few years ago with a QT project.
Even if it may look like conterintuitive i solved changing:
item:hover
to
item:selected
I was advised so on QT forum, in that contest :selected acted as :hover, i didn't get deeper in the question, maybe won't work, but it worth a try.
I intend to set the background color of the QWidget
QWidget {
background-color: white;
}
But later, when the menu QAction is selected, the font is white, and the background is also white.The menu button font and background can be reset in the following ways
QMenu::item:hover {}
to
QMenu::item:selected {}
This way works, thanks
Related
The problem is I want to make the gray button hidden and get revealed after hovering on a card with hotel pictures.
Currently, I have this site as an example: https://cofffelo.github.io/HotelShop/#
I tried to hide the buttons at their default state by display:none and make it display:block by executing :hover pseudo-index, but because it was hidden from the start, there was nothing to hover, and because I'm kind of a newbie, I ran out of ideas.
The code I tried to add:
.cardbutton{
display: none;
}
.cardbutton:hover{
transform: translateY(30px);
display: block;
background-color: #333;
}
You can use a transition delay
.cardbutton:after {
opacity: 0;
content: "";
}
.cardbutton:hover:after {
opacity: 1;
transition: opacity 0s linear 1.5s;
content: "content text here";
}
I have following stylesheet for table.
QHeaderView::section, *[role="mockheader"]
{
min-width:80px;
background-color:#3949ab;
color:#FFFFFF;
border:0px;
outline:none;
height:40px;
}
QHeaderView::section:checked, QHeaderView::section:hover
{
background-color: #3949ab;
color:white;
}
QTableView
{
show-decoration-selected: 1;
border:0px;
background-color: rgba(0, 0, 0, 0);
gridline-color:#454545;
color: #FFFFF8;
}
QTableView::item
{
border: 0px;
min-height:35px;
padding:5px;
color:#FFFFFF;
}
QTableView::item:hover
{
background-color: rgba(255,255,255, 50);
}
QTableView::item:selected
{
background-color: #3949ab;
}
Ideally it should paint header in blue color. it is seems unaffected. see attached snap.
*Left blue space is label, which i added for filling left space. Its not a part of table. Just leave it.
I am not able to figure out any problem in my stylehseet. Please let me know what I am doing wrong here.
I have slide where I set the paginationStyle="progress" how can I change the color of the progressbar?
<ion-slides #exercisesSlider pager paginationType="progress">
Could somebody provide me a way to change the color of the progressbar?
Ionic uses Swiper API slides. So you can select using class names swiper-pagination-progress and swiper-pagination-progressbar like this:
.swiper-pagination-progress .swiper-pagination-progressbar {
background:red;
}
Using only the CSS borders worked for me :
.swiper-pagination-progressbar-fill {
border: 2px solid rgba(175, 240, 122, 0.719);
border-radius: 5px;
}
.swiper-pagination-progressbar {
background-color: rgba(255, 255, 255, 0.3);
border-radius: 5px;
}
Simple and maybe obvious follow up from the answer from #Surya Teja . If you separate the classes you can control which color for each part of the progress bar.
.swiper.pagination-progress {
background-color: red
}
.swiper-pagination-progressbar {
background-color: white
}
I have a QStyledItemDelegate with custom painting. Each item comprises some text and a progress bar. The progress bar is circular (radial) so it is custom-drawn too:
Also my application uses QSS for some custom styling.
This item delegate was used in a QListView.
I want be able to set different ProgressBar chunk colors for 100% and non-100% with QSS.
Question
Is there any way to know color for progress bar chunk for current QSS?
Investigation and code I've tried:
QSS:
QProgressBar { border: 1px solid #909090; ; }
QProgressBar[value="100"]::chunk {
width: 10px;
margin: 0.5px;
background-color: rgb(50,145,212);
}
QProgressBar::chunk {
width: 10px;
margin: 0.5px;
background-color: rgb(81,211,49);
}
C++:
QStyleOptionProgressBarV2 pbStyleOption;
{
boost::scoped_ptr<QProgressBar> pb(new QProgressBar());
pb->setStyle(QApplication::style());
pb->setStyleSheet(static_cast<QApplication*>(QApplication::instance())->styleSheet());
pb->setValue(progressPercentage);
pb->setMaximum(100);
pbStyleOption.initFrom(pb);
qDebug() << pbStyleOption.palette.brush(QPalette::Highlight);
}
I'm using QPalette::Highlight because I looked into Qt's source for styles and it uses this ColorRole for PE_IndicatorProgressChunk.
P.S.
QSS above works only for a slightly modified QProgressBar. The only modification is a reimplemented setValue(). Here is its code:
void StyledProgressBar::setValue(int val)
{
QProgressBar::setValue(val);
style()->unpolish(this);
style()->polish(this);
update();
}
How to set background image for QLineEdit? The following style sheet doesn't work
QLineEdit {
background-image:url(:/images/13.png);
}
QLineEdit {
border: 1px solid #000000; //image work with this line and didn't work with out))
image: url(:/images/13.png);
}
better solution is:
#fileFilter
{
background: url(/Users/karelhladky/Pictures/Icons/famfamfam/icons/emoticon_grin.png);
// there is no need add border property
}