Originally Posted by
Pavel Abrosimov
The QLabels didn't show with that properly as it was only first letter was seen from any label.
The trick with QPainter did it's job - there is a loop for all required text and painter draws it:
painter.drawText(x, y, text);
So what are the labels for if you're drawing the text manually?
To me the problem seems to be caused by the fact that you are not using layouts and that you completely ignore setting geometry of the labels, so it's quite obvious you see nonsense.
#include <QLabel>
#include <QApplication>
int main(int argc, char **argv){
for(int i=0;i<10;i++){
l
->setText
(QString("Label %1").
arg(i
+1));
l->setGeometry(i*20, i*20, l->sizeHint().width(), l->sizeHint().height());
}
w.show();
return app.exec();
};
#include <QLabel>
#include <QApplication>
int main(int argc, char **argv){
QApplication app(argc, argv);
QWidget w;
for(int i=0;i<10;i++){
QLabel *l = new QLabel(&w);
l->setText(QString("Label %1").arg(i+1));
l->setGeometry(i*20, i*20, l->sizeHint().width(), l->sizeHint().height());
}
w.show();
return app.exec();
};
To copy to clipboard, switch view to plain text mode
Bookmarks