I am new to Qt and C++ and working on an application and I am trying to add QLabel
in a QWidget
, using QHBoxLayout
.
I am setting the text of label to something but it is not visible in the Label.
Here is the piece of the code:
setStyleSheet( "QWidget{ background-color : rgba( 160, 160, 160, 255); border-radius : 7px; }" );
QLabel *label = new QLabel(this);
QHBoxLayout *layout = new QHBoxLayout();
label->setText("Random String");
layout->addWidget(label);
setLayout(layout);
The styleSheet is for the Widget in which QLabel is added.
The string "Random String"
doesn't get displayed inside the label.
Please help.