/*! With this function you can set the skin that will be displayed in the widget. \code QtScrollDial * scroll = new QtScrollDial(this); scroll->setSkin("Beryl"); \endcode This function has to be called before using the QtScrollDial. \sa skin() */ void QtScrollDial::setSkin(const QString& skin) { m_skin = skin; const QString base = ":/scrolldial/" + skin + '/'; if(m_popup != NULL) m_popup->setSkin(skin); m_label->setStyleSheet("color: white; border-width: 2px;" "border-image: url(" + base + "label.svg);"); // set to null pictures m_background = QPicture(); m_hoverBackground = QPicture(); QSvgRenderer renderer; QPainter painter; if (renderer.load(base + "background.svg")) { painter.begin(&m_background); renderer.render(&painter, QRectF(0.0, 0.0, 1.0, 1.0)); painter.end(); } if (renderer.load(base + "background_hover.svg")) { painter.begin(&m_hoverBackground); renderer.render(&painter, QRectF(0.0, 0.0, 1.0, 1.0)); painter.end(); } // update geometry for new sizeHint and repaint updateGeometry(); update(); }
void tst_QPicture::serialization() { QDataStream stream; const int thisVersion = stream.version(); for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) { const QDataStream::Version versionEnum = static_cast<QDataStream::Version>(version); { // streaming of null pictures ensureSerializesCorrectly(QPicture(), versionEnum); } { // picture with a simple line, checking bitwise equality QPicture picture; QPainter painter(&picture); painter.drawLine(10, 20, 30, 40); ensureSerializesCorrectly(picture, versionEnum); } } { // Test features that were added after Qt 4.5, as that was hard-coded as the major // version for a while, which was incorrect. In this case, we'll test font hints. QPicture picture; QPainter painter; QFont font; font.setStyleName("Blah"); font.setHintingPreference(QFont::PreferFullHinting); painter.begin(&picture); painter.setFont(font); painter.drawText(20, 20, "Hello"); painter.end(); Picture customPicture; painter.begin(&customPicture); picture.play(&painter); const QFont actualFont = ((PaintEngine*)customPicture.paintEngine())->font(); painter.end(); QCOMPARE(actualFont.styleName(), QStringLiteral("Blah")); QCOMPARE(actualFont.hintingPreference(), QFont::PreferFullHinting); } }
## GNU General Public License Usage ## Alternatively, self file may be used under the terms of the GNU ## General Public License version 3.0 as published by the Free Software ## Foundation and appearing in the file LICENSE.GPL included in the ## packaging of self file. Please review the following information to ## ensure the GNU General Public License version 3.0 requirements will be ## met: http://www.gnu.org/copyleft/gpl.html. ## ## If you are unsure which license is appropriate for your use, please ## contact the sales department at http://www.qtsoftware.com/contact. ## $QT_END_LICENSE$ ## ############################################################################ //! [0] picture = QPicture() painter = QPainter() painter.begin(picture) # paint in picture painter.drawEllipse(10,20, 80,70) # draw an ellipse painter.end() # painting done picture.save("drawing.pic") # save picture //! [0] //! [1] picture = QPicture() picture.load("drawing.pic") # load picture painter = QPainter() painter.begin(myImage) # paint in myImage painter.drawPicture(0, 0, picture) # draw the picture at (0,0) painter.end() # painting done //! [1]