[Interest] How are High DPI Icons supposed to work?
Julius Bullinger
Julius.Bullinger at asctec.de
Fri Sep 25 13:19:18 CEST 2015
Dear List,
is there any clear and concise How To for High DPI icons/pixmaps? I gathered some information from several Wiki pages, Blog posts and documentation pages [1-7], but no luck.
My MNWE (minimal not working example):
// from main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
MainWindow w;
w.show();
return a.exec();
}
// from mainwindow.cpp
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QPixmap pixmap(":/icons/48x48/icon.png");
QPixmap pixmap2x(":/icons/48x48/icon at 2x.png");
pixmap2x.setDevicePixelRatio(2);
QLabel* pbLabel = new QLabel();
pbLabel->setText(tr("PushButton:"));
QPushButton* pushButton = new QPushButton();
pushButton->setIcon(pixmap2x);
pushButton->setIconSize(QSize(48, 48));
QVBoxLayout* layout = new QVBoxLayout();
layout->addWidget(pbLabel);
layout->addWidget(pushButton);
QWidget* centralWidget = new QWidget();
centralWidget->setLayout(layout);
setCentralWidget(centralWidget);
}
What am I missing?
Best regards,
Julius
[1]: http://blog.qt.io/blog/2013/04/25/retina-display-support-for-mac-os-ios-and-x11/
[2]: http://wiki.qt.io/Icons_In_Qt_Quick_Controls
[3]: http://doc.qt.io/qt-5/scalability.html
[4]: http://doc.qt.io/qt-5/qicon.html#pixmap
[5]: http://doc.qt.io/qt-5/highdpi.html
[6]: http://www.kdab.com/pixels-trust-scalable-uis-qml-part-2/
[7]: https://bugreports.qt.io/browse/QTBUG-44486
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150925/f51bbcc0/attachment.html>
More information about the Interest
mailing list