
Originally Posted by
Adam Badura
Yes, but only the height and width, not every exact position of the elements. Also I guess the count of labels is known and static, so you can cache that information. So it would be easy:
int countOfLabels = 3; // or whatever
int h = 0;
h = countOfLabels * (fontmetrics.height() + padding)
h = qMax(h, heightOfThumbnail);
int countOfLabels = 3; // or whatever
int h = 0;
h = countOfLabels * (fontmetrics.height() + padding)
h = qMax(h, heightOfThumbnail);
To copy to clipboard, switch view to plain text mode
Also I considered using columns.
Also that doesn't change much of my example:
QList<QPair<QString,QString> > labels; // a pair has "label:value"
// Draw the pixmap
int currentX = pixmap.width() + padding /* +... */;
// then drawing
int height = fontmetrics.height() + padding;
for(int i = /*...*/) {
painter
->drawText
(QRect(currentX, i
*height, maxDescWidth, height
), Qt
::AlignRight, labels.
at(i
).
first);
// same for the text.
}
QList<QPair<QString,QString> > labels; // a pair has "label:value"
// Draw the pixmap
int currentX = pixmap.width() + padding /* +... */;
// then drawing
int height = fontmetrics.height() + padding;
for(int i = /*...*/) {
painter->drawText(QRect(currentX, i*height, maxDescWidth, height), Qt::AlignRight, labels.at(i).first);
// same for the text.
}
To copy to clipboard, switch view to plain text mode
The solution with a QWidget is possible but then you could simply use Q***Widget. And also the delegate functions are called quite a lot so it isn't with good performance.
Bookmarks