#include #include #include #include #include #include void testFont() { QFont font("Arial", 21); //font.setItalic(m_attr.fontItalics); font.setStyleStrategy(QFont::NoAntialias); QFontMetricsF metric(font); QFontMetrics metricI(font); qDebug()<<"QFontMetrics"; qDebug()<<" leading"< #include class TestWin : public QWidget { public: TestWin(){ resize(400, 100); auto hBox = new QHBoxLayout(this); hBox->setContentsMargins(100,0,0,0); aaa = new QLabel("Aaaaaaaaaaaaaaaaaaaaaaaa"); aaa->setAutoFillBackground(true); QPalette pal; pal.setColor(QPalette::Window, Qt::darkGreen); aaa->setPalette(pal); aaa->setMinimumWidth(10); hBox->addWidget(aaa); bbb = new QLabel("B"); bbb->setAutoFillBackground(true); pal.setColor(QPalette::Window, Qt::darkCyan); bbb->setPalette(pal); bbb->setMinimumWidth(1); auto poli = aaa->sizePolicy(); poli.setHorizontalPolicy(QSizePolicy::Expanding); aaa->setSizePolicy(poli); bbb->setSizePolicy(poli); hBox->addWidget(bbb); } void mouseDoubleClickEvent(QMouseEvent *) override { qDebug()<<"sizeHint "<sizeHint()<sizeHint(); qDebug()<<"minHint "<minimumSizeHint()<minimumSizeHint(); qDebug()<<"sizePolicy"<sizePolicy()<sizePolicy(); qDebug()<<"minSize "<minimumSize()<minimumSize(); qDebug()<<"maxSize "<maximumSize()<maximumSize(); qDebug()<<"size "<size()<size(); } QWidget *aaa; QWidget *bbb; }; int tttmain(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); QApplication a(argc, argv); QFont font = a.font(); font.setPointSize(14); a.setFont(font); TestWin w; w.show(); return a.exec(); }