
Originally Posted by
wysota
Show the code please.
I think I narrowed down the code to this. MyLabel is inherited from QLabel. I want it to change size (to maximum space) when I resize the window. It looks like it is not resizing automatically after this resize event. Is there some method I'm missing here ?
{
int minPointSize=14;
const QSize& sz=ev->size();
const QFont& fnt=font();
qDebug() << "Resize event:" << sz << "pixelsize:" << f.pixelSize()
<< "." << f.pointSize();
f.setPointSize(sz.height()/2);
if (f.pointSize() < minPointSize) {
f.setPointSize(minPointSize);
}
setFont(f);
}
void MyLabel::resizeEvent(QResizeEvent* ev)
{
int minPointSize=14;
const QSize& sz=ev->size();
const QFont& fnt=font();
QFont f=fnt;
qDebug() << "Resize event:" << sz << "pixelsize:" << f.pixelSize()
<< "." << f.pointSize();
f.setPointSize(sz.height()/2);
if (f.pointSize() < minPointSize) {
f.setPointSize(minPointSize);
}
setFont(f);
}
To copy to clipboard, switch view to plain text mode
Bookmarks