qlabel

Displaying Integers on QLabels?

你离开我真会死。 提交于 2019-11-27 06:29:15
问题 Basically i'm making a simple calculator program to understand the basics of C++ GUI however I get an error message leading to the line of code I have in the void MainWindow::addx() to label -> setText(c); with an error message of: invalid user-defined conversion from 'int' to 'const QString&'[-fpermissive] I really don't know what that error message means I assume it means I cant display an integer on a label. I just wanted to know if I am able to display an integer on my label or do I have

QLabel does not display in QWidget

狂风中的少年 提交于 2019-11-26 23:13:28
I have the following hierarchy in my Qt Application: QMainWindow > QWidget (centralWidget) > QWidget (subclassed) > QLabel Initialization code in my QMainWindow code: centralWidget = new QWidget(); centralWidget->setGeometry(0,0,width,height); chatWidget=new ChatWidget(this); // the subclassed QWidget setCentralWidget(centralWidget); In my subclassed QWidget initialization (which happens at the same time than the Qt App initialization) I have the following code: ChatWidget::ChatWidget(QWidget *parent):QWidget(parent) { QLabel *lbl; lbl=new QLabel(this); lbl->setText("Hello World 1"); <-- Is

Change QLabel text dynamically in PyQt4

点点圈 提交于 2019-11-26 21:02:53
问题 My question is: how can I change the text in a label? The label is inside a layout, but setText() does not seem to work - maybe I am not doing it right. Here is my code: this is the Main windows GUI, the one Qt-Designer gives: class Ui_dashboard(QtGui.QMainWindow): def setupUi(self, dashboard): dashboard.setObjectName(_fromUtf8("dashboard")) dashboard.resize(734, 703) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8("../../../../Documents and Settings/cgarcia/Escritorio/metromara -

QLabel: set color of text and background

旧巷老猫 提交于 2019-11-26 09:17:55
问题 How do I set color of text and background of a QLabel ? 回答1: The best and recommended way is to use Qt Style Sheet. To change the text color and background color of a QLabel , here is what I would do : QLabel* pLabel = new QLabel; pLabel->setStyleSheet("QLabel { background-color : red; color : blue; }"); You could also avoid using Qt Style Sheets and change the QPalette colors of your QLabel , but you might get different results on different platforms and/or styles. As Qt documentation states

QLabel does not display in QWidget

主宰稳场 提交于 2019-11-26 06:08:21
问题 I have the following hierarchy in my Qt Application: QMainWindow > QWidget (centralWidget) > QWidget (subclassed) > QLabel Initialization code in my QMainWindow code: centralWidget = new QWidget(); centralWidget->setGeometry(0,0,width,height); chatWidget=new ChatWidget(this); // the subclassed QWidget setCentralWidget(centralWidget); In my subclassed QWidget initialization (which happens at the same time than the Qt App initialization) I have the following code: ChatWidget::ChatWidget(QWidget