Hi,
I’m trying to achieve a simple layout
[QLabel1 (image)] [QLabel2]
[Widget here ——————— ]
The layout works when QLabel1 is displaying some text, but when I show an image in the QLabel using stylesheet, the alignement is all over the place, see screenshot below
-“AlignLeft example”:https://www.dropbox.com/s/i81sg8p8m1v4a47/alignLeftQLabel.png
-“AlignRight example”:https://www.dropbox.com/s/26r7g04po4ip11m/aligntRightQLabel.png
Code for building the layout :
QVBoxLayout *layout = new QVBoxLayout( this );
QHBoxLayout *hlayout = new QHBoxLayout();
hlayout->setSpacing( 5 );
hlayout->addWidget( d_label_icon );
hlayout->addWidget( d_label_current_value );
d_label_icon->setText("d");
d_label_icon->setAlignment(Qt::AlignRight); // only the text moves right!
d_label_current_value->setAlignment(Qt::AlignLeft);
layout->setSpacing( 5 );
layout->addLayout(hlayout);
layout->addWidget( d_dial );
If someone know a workaround, i’m stuck with this since a long time, maybe using something else that a QLabel to show the image? I tried multiple layout, grid, etc. all ignores the alignment of the image.
Image is set with style sheet (d_label_icon->setStyleSheet(“image: url(:/image/icon/heart2)”);)
Thanks in advance!
↧