qtstylesheets

Center the Text of QTextEdit horizontally and vertically

怎甘沉沦 提交于 2019-11-27 07:25:39
问题 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? 回答1: If you only need one line, you can use a QLineEdit instead: QLineEdit* lineEdit = new QLineEdit("centered text"); lineEdit->setAlignment(Qt:

QWidget does not draw background color

邮差的信 提交于 2019-11-27 05:20:21
I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here's the ui-XML: <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class>

How to set stylesheet for the current item in QTableView

爷,独闯天下 提交于 2019-11-26 18:27:27
问题 When QTableView edit control is visible for the current item the shylesheet of the edit takes place. When there is no active edit control in the QTableView the current item is styled using the QTableView { selection-background-color: } How to set different style only for the current item? 回答1: Qt style sheets support sub-controls and pseudo states, you can use it to improve your customization. (see http://qt-project.org/doc/qt-5/stylesheet-reference.html#list-of-pseudo-states ) In this case

Qt Stylesheet for custom widget

淺唱寂寞╮ 提交于 2019-11-26 17:32:05
I have several custom widget in my current project. I wish to apply stylesheets to them and when I do so inside Qt Creator, it appears to work. However, when executing the program, no stylesheet is used. The stylesheets for the Qt widgets are working normally. Does anyone have any advice? here is some relevant code. WidgetUnits.h #ifndef WIDGETUNITS_H #define WIDGETUNITS_H #include <QList> #include <QWidget> #include <QPainter> #include <Widgets/JECButton.h> #include <Unit.h> #include <Time.h> namespace Ui { class WidgetUnits; } class WidgetUnits : public QWidget { Q_OBJECT public: explicit

QWidget does not draw background color

自古美人都是妖i 提交于 2019-11-26 11:31:07
问题 I am using PySide 1.2.1 with Python 2.7 and I need a widget to draw a colored background. In Qt Designer I created a simple window consisting of a label, a widget containing three other items and another label. For the widget containing the button, radio button and checkbox I set the styleSheet property to background-color: #FFFFFF . In Qt Designer everything renders as desired: But in Pyside the widget does not draw the background color - but the items on it inherit the color correctly: Here