Have some problem with corner widget due using non-standard font size in app, screenshot to be clear:
code:
QToolButton* m_exit = new QToolButton(m_tab);
m_exit->setIcon(QIcon(":/Resources/exit.png"));
m_exit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
m_tab->setCornerWidget(m_exit, Qt::TopRightCorner);
font changing via
QApplication::setFont(...);
How can i do corner button same size as tab-buttons size?
P.S. using setStyleSheet( "QTabBar::tab { min-height: 120px; }" ); not allowed
You can use the ::right-corner sub-control in your stylesheet. There you can set the height of the corner button (you'd probably have to adjust the bottom too). Set both heights (corner button and tab) to the same value.
QTabWidget::right-corner {
height: 30px;
bottom: 10px;
}
QTabBar::tab {
height: 30px;
}
Related
i'm trying to create a box-shadow effect for my customs widget, but i can't find a way to do that!.
Using QGraphicsDropShadowEffect class generate a shadow that is the copy of the shape of the widget itself and put that copy behind the widget. So, when i set a opacity of 50% to my widget, the shadow is seeing trought the widget, and what i want to achive is something more like the box-shadow effect pressent in the web CSS styles, for example:
css generated:
https://i.ibb.co/mG1XXG2/box-shadow-qt-ask1.png
QGraphicsDropShadowEffect generated:
https://i.ibb.co/y680RKx/box-shadow-qt-ask2.png
As you can see, both of my elements has a shadow, and a opacity of 50%, the css generate haven't a shadow visible trought the semi transparent div element, but the shadow generated by QGraphicsDropShadowEffect can be seeing thounght the semi transparent widget, there's some way to achive to create a custom shadow that behave like css box-shadow but on my Qt/c++ widget?
Sorry if i'm not clear enoungh, i'm not an expert speaking english.
Thank you for your patience.
A cheat would be to group your object + drop shadow as a single item. Whilst making that entire object invisible, you copy the entire item with a dummy OpacityMask. Then, you apply the opacity to the OpacityMask.
For example:
import QtQuick
import QtQuick.Controls
import Qt5Compat.GraphicalEffects
Page {
background: Rectangle { color: "#ccc" }
Frame {
id: butterflyWithBoxShadow
anchors.centerIn: parent
visible: false
padding: 15
background: Item {
Rectangle {
anchors.fill: parent
anchors.leftMargin: butterflyWithBoxShadow.padding * 2
anchors.topMargin: butterflyWithBoxShadow.padding * 2
color: "grey"
opacity: 0.5
}
}
Frame {
id: frame
padding: 1
background: Rectangle {
border.color: "blue"
border.width: 1
color: "#ffe"
}
Image {
id: butterfly
fillMode: Image.PreserveAspectFit
source: "https://www.arcgis.com/sharing/rest/content/items/185841a46dd1440d87e6fbf464af7849/data"
smooth: true
}
}
}
OpacityMask {
anchors.fill: butterflyWithBoxShadow
source: butterflyWithBoxShadow
invert: true
opacity: slider.value
}
Frame {
anchors.horizontalCenter: parent.horizontalCenter
y: parent.height * 8 / 10
background: Rectangle { }
Slider {
id: slider
from: 0
to: 1
value: 0.8
}
}
}
You can Try it Online!
auto bar = ui->verticalScrollBar();
bar->setStyleSheet("QScrollBar:vertical { width: 20px; }"
"QScrollBar::up-arrow:vertical, QScrollbar::down-arrow:vertical { width: 15px; height: 15px; }");
I cannot resize the arrows. scrollbar
Already checked stylesheet example here http://doc.qt.io/qt-5.6/stylesheet-examples.html
Any idea would be appreciated.
Try to use min-width, max-width (the same value), min-height, max-height (the same value) instead of width and height.
I'm trying to get equal height columns on my responsive grid using the gallery mixin for SUSY. To do that, I set the container "display: table" and the column "display: table-cell". This works for me if I do not use the mixin, but fails as soon as I turn on the mixin. The mixin works if I have set the height in pixels, but not if I set the height using 100%;
I'm using:
susy (2.1.3) and
sass (~> 3.3)
This works with or without SUSY:
.ttable {
#include container;
padding: gutter();
#include clearfix;
.ttd {
#include gallery(3 of 12);
}
}
.ttable {
display: table;
height: 500px;
border: 1px solid #BF0D3E;;
}
.ttd {
display: table-cell;
background-color: #eee;
height: 500px;
}
This doesn't work with SUSY, but works with the mixin turned off:
.ttable {
display: table;
height: 100%;
border: 1px solid $fuschia;
}
.ttd {
display: table-cell;
background-color: #eee;
height: 100%;
}
The gallery mixin uses floats and margins to position elements, which won't work with table display. The first one works because the table styles are ignored, and the items are floated with a set height. If you want to use table styles to get equal-heights, you should leave out the gallery mixin, and use individual mixins/functions to set width/gutters instead (I think only inside and inside-static gutters will work with table display).
.ttd {
#include gutters;
display: table-cell;
background-color: #eee;
width: span(3 of 12);
}
How can I set a background image for the QTabWidget in Qt?
I've already tried the following code, but it doesn't work:
ui->tabWidget->setStyleSheet("background-image: url(:/images/img.jpg);");
And can I set a background image for the specific tab of the QTabWIdget?
This is the code to set the style of QTabWidget Tab and set Image on to it:
QString category = "QTabBar::tab:first { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/category.png); }";
QString counter= "QTabBar::tab:middle { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/counter.png); }";
QString user="QTabBar::tab:last { height: 30px; width: 100px;border-image: url(/home/vx/Downloads/Images/user.png); }";
ui->TB_main->tabBar()->setStyleSheet(category+counter+user);
I am using a stlyesheet to style my qt pushbutton when the mouse moves over it. However, the hover event only fires when I CLICK on the button, nothing happens when I hover my mouse over it
Trackbox { background: #FFFFFF;}
QPushButton {
position: fixed;
top: 2px;
right: 2px;
width: 20px;
height: 20px;
}
QPushButton:hover { background: #c0ffff}
Any help is appreciated. Thanks
This was a very simple fix. I needed to add a boarder, o px, for hover to work correctly. Thanks for all the help.