Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the general methods and class libraries of Qt

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what are the general methods and class libraries for Qt". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what general methods and class libraries are available in Qt.

Function name / / Nine grid pictures horzSplit- grid 1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (horzSplit-); static QPixmap ninePatch (const QPixmap & pix, int horzSplit, int vertSplit, int dstWidth, int dstHeight) Function body QPixmap QUIHelper::ninePatch (const QString & picName, int horzSplit, int vertSplit, int dstWidth, int dstHeight) {QPixmap pix (picName); return ninePatch (pix, horzSplit, vertSplit, dstWidth, dstHeight);} QPixmap QUIHelper::ninePatch (const QPixmap & pix, int horzSplit, int vertSplit, int dstWidth, int dstHeight) {int pixWidth = pix.width (); int pixHeight = pix.height (); QPixmap pix1 = pix.copy (0,0, horzSplit, vertSplit) QPixmap pix2 = pix.copy (horzSplit, 0, pixWidth-horzSplit * 2, vertSplit); QPixmap pix3 = pix.copy (pixWidth-horzSplit, 0, horzSplit, vertSplit); QPixmap pix4 = pix.copy (0, vertSplit, horzSplit, pixHeight-vertSplit * 2); QPixmap pix5 = pix.copy (horzSplit, vertSplit, pixWidth-horzSplit * 2, pixHeight-vertSplit * 2); QPixmap pix6 = pix.copy (pixWidth-horzSplit, vertSplit, horzSplit, pixHeight-vertSplit * 2) QPixmap pix7 = pix.copy (0, pixHeight-vertSplit, horzSplit, vertSplit); QPixmap pix8 = pix.copy (horzSplit, pixHeight-vertSplit, pixWidth-horzSplit * 2, pixWidth-horzSplit * 2); QPixmap pix9 = pix.copy (pixWidth-horzSplit, pixHeight-vertSplit, horzSplit, vertSplit); / / maintain height widening pix2 = pix2.scaled (dstWidth-horzSplit * 2, vertSplit, Qt::IgnoreAspectRatio) / / keep the width high pix4 = pix4.scaled (horzSplit, dstHeight-vertSplit * 2, Qt::IgnoreAspectRatio); / / scale both width and height pix5 = pix5.scaled (dstWidth-horzSplit * 2, dstHeight-vertSplit * 2, Qt::IgnoreAspectRatio); / / keep the width high pix6 = pix6.scaled (horzSplit, dstHeight-vertSplit * 2, Qt::IgnoreAspectRatio); / / keep the height stretch pix8 = pix8.scaled (dstWidth-horzSplit * 2, vertSplit) / / generate width and height images and fill them with transparent background colors QPixmap resultImg (dstWidth, dstHeight); resultImg.fill (Qt::transparent); QPainter painter; painter.begin (& resultImg); if (! resultImg.isNull ()) {painter.drawPixmap (0,0, pix1); painter.drawPixmap (horzSplit, 0, pix2); painter.drawPixmap (dstWidth-horzSplit, 0, pix3); painter.drawPixmap (0, vertSplit, pix4) Painter.drawPixmap (horzSplit, vertSplit, pix5); painter.drawPixmap (dstWidth-horzSplit, vertSplit, pix6); painter.drawPixmap (0, dstHeight-vertSplit, pix7); painter.drawPixmap (horzSplit, dstHeight-vertSplit, pix8); painter.drawPixmap (dstWidth-horzSplit, dstHeight-vertSplit, pix9);} painter.end (); return resultImg } Thank you for your reading, the above is the content of "what are the general methods and class libraries of Qt". After the study of this article, I believe you have a deeper understanding of what general methods and class libraries of Qt have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 280

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report