qtstylesheets

Qt TabWidget Each tab Title Background Color

谁都会走 提交于 2019-11-29 16:36:11
This is the original Tabwidget without setting title background color My customer ask me to do something like this; Set different background colour for title All - Yellow purchase - light blue POS Sales - light green Cash Sales - Pink invoice - light purple I have try the SetStyleSheet like: QTabBar { background-color : Yellow; } But all tab Color changed Somebody know how to setting each QTabBar background color? These properties can not be set through QSS. To change the style to each tab we must create a custom QTabBar and override its paintEvent method, to be able to change the style of

Hide QScrollBar arrows

孤街醉人 提交于 2019-11-29 13:15:55
How to hide QScrollBar arrows? I need to hide in horizontal scrollbar. I was trying to hide with setStyleSheet : setStyleSheet(" QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal { height:0px; }" ) but it doesn't work. If you need to hide just the arrows inside buttons then you can try to set background and border in this way: QScrollBar::right-arrow:horizontal, QScrollBar::left-arrow:horizontal { border: none; background: none; color: none; } If you want to hide whole buttons then you go with code below. QScrollBar::add-line:horizontal { border: none; background: none; }

changing stylesheet dynamically

做~自己de王妃 提交于 2019-11-29 11:36:33
I'm trying to change the style of my QLabel using a dynamic property since we can target this property in QSS like this: QLabel[foo = "warning"]{ color: red; } QLabel[foo = "success"]{ color: green; } the stye of my label does update when I use the QApplication::setStyleSheet() but does not seems to work when I change the value of the property. label = new QLabel( this ); label->setText( "some text" ); label->setProperty( "foo", "warning"); // after some event label->setProperty( "foo", "success" ); // the label's color should be green now did I missed something, or the style change can just

How to override just one property:value pair in Qt StyleSheet

隐身守侯 提交于 2019-11-29 05:47:27
I am writing newbie Qt5 code on OSX Mavericks and would like to override just one property:value pair of the StyleSheet for a given widget. If I run the following self-contained demonstration code: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QPushButton> int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QMainWindow* mw = new QMainWindow(); QPushButton* AButton = new QPushButton( "A Button", mw ); mw->show(); return app.exec(); } I get a nice pushbutton with Macintosh style defaults -- rounded corners, standard OSX-blue color when pressed, etc.:

Qt: Styling QTabWidget

社会主义新天地 提交于 2019-11-28 18:27:27
I'm using Qt and I have a QTabWidget setup in the Qt Designer Editor, you can see it in picture 1. As you can see after Tab4 there is an empty space all the way to the right edge, in someway I need to fill that space with a color, like in picture 2 (the best thing would be to be able to set a fading color). Or another solution would be that the tabs float out to cover the whole screen. I use the following stylesheet right now: QTabWidget::tab-bar { } QTabBar::tab { background: gray; color: white; padding: 10px; } QTabBar::tab:selected { background: lightgray; } Is there a way to set the

Center the Text of QTextEdit horizontally and vertically

空扰寡人 提交于 2019-11-28 12:53:56
I want to center the text of my QTextEdit horizontally and vertically. I tried this, but it didn't work. m_myTextEdit = new QTextEdit("text edit", m_ui->centralWidget); m_myTextEdit->setGeometry(5, 50, 400, 250); m_myTextEdit->setReadOnly(true); m_myTextEdit->setAlignment(Qt::AlignCenter); Is there a opportunity to set it centered with a StyleSheet? If you only need one line, you can use a QLineEdit instead: QLineEdit* lineEdit = new QLineEdit("centered text"); lineEdit->setAlignment(Qt::AlignCenter); If you only want to display the text, not allow the user to edit it, you can use a QLabel

Hide QScrollBar arrows

余生颓废 提交于 2019-11-28 07:12:41
问题 How to hide QScrollBar arrows? I need to hide in horizontal scrollbar. I was trying to hide with setStyleSheet : setStyleSheet(" QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal { height:0px; }" ) but it doesn't work. 回答1: If you need to hide just the arrows inside buttons then you can try to set background and border in this way: QScrollBar::right-arrow:horizontal, QScrollBar::left-arrow:horizontal { border: none; background: none; color: none; } If you want to hide whole

Qt stylesheet, background image from filepath

巧了我就是萌 提交于 2019-11-28 05:25:02
问题 All examples I have found so far refer to background images in the resource file. Something like: QFrame { background-image: url(:/images/header.png); } I wonder, is there a way to use a file directly from the file system? Something like: background-image: url("C:\temp\foo.jpg"); ???? background-image: file("C:\temp\foo.jpg"); ???? I have tried all kind of urls, but none is working. Do I always have to add the file in the resources? 回答1: You don't necessarily need add your files as resources.

How to override just one property:value pair in Qt StyleSheet

怎甘沉沦 提交于 2019-11-27 23:39:33
问题 I am writing newbie Qt5 code on OSX Mavericks and would like to override just one property:value pair of the StyleSheet for a given widget. If I run the following self-contained demonstration code: #include <QApplication> #include <QMainWindow> #include <QtGui> #include <QPushButton> int main( int argc, char *argv[] ) { QApplication app( argc, argv ); QMainWindow* mw = new QMainWindow(); QPushButton* AButton = new QPushButton( "A Button", mw ); mw->show(); return app.exec(); } I get a nice

Qt: Styling QTabWidget

拜拜、爱过 提交于 2019-11-27 11:21:08
问题 I'm using Qt and I have a QTabWidget setup in the Qt Designer Editor, you can see it in picture 1. As you can see after Tab4 there is an empty space all the way to the right edge, in someway I need to fill that space with a color, like in picture 2 (the best thing would be to be able to set a fading color). Or another solution would be that the tabs float out to cover the whole screen. I use the following stylesheet right now: QTabWidget::tab-bar { } QTabBar::tab { background: gray; color: