diff --git a/examples/qvgviewer/MainWindow.cpp b/examples/qvgviewer/MainWindow.cpp index 001c6c87..5d63002e 100644 --- a/examples/qvgviewer/MainWindow.cpp +++ b/examples/qvgviewer/MainWindow.cpp @@ -31,8 +31,8 @@ class GraphicLabel : public QskGraphicLabel Inverted }; - GraphicLabel( const QskGraphic& graphic, QQuickItem* parent = nullptr ) - : QskGraphicLabel( graphic, parent ) + GraphicLabel( QQuickItem* parent = nullptr ) + : QskGraphicLabel( parent ) { setMargins( 10 ); setPanel( true ); @@ -74,7 +74,7 @@ class GraphicLabel : public QskGraphicLabel MainWindow::MainWindow() { - auto label = new GraphicLabel( QskGraphicIO::read( QString( ":/qvg/Tux.qvg" ) ) ); + auto label = new GraphicLabel(); auto invertButton = new QskPushButton( "Inverted" ); invertButton->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed ); @@ -98,6 +98,12 @@ MainWindow::MainWindow() setGraphicRoles( qskSkinManager->skin() ); } +void MainWindow::setGraphic( const QString& path ) +{ + if ( auto label = findChild< QskGraphicLabel* >() ) + label->setGraphic( QskGraphicIO::read( path ) ); +} + void MainWindow::setGraphicRoles( QskSkin* skin ) { // substituting black diff --git a/examples/qvgviewer/MainWindow.h b/examples/qvgviewer/MainWindow.h index 2d8eb8b5..f486af93 100644 --- a/examples/qvgviewer/MainWindow.h +++ b/examples/qvgviewer/MainWindow.h @@ -15,6 +15,7 @@ class MainWindow : public QskWindow public: MainWindow(); + void setGraphic( const QString& ); private Q_SLOTS: void setGraphicRoles( QskSkin* ); diff --git a/examples/qvgviewer/main.cpp b/examples/qvgviewer/main.cpp index 9dc3ede2..fc1421bb 100644 --- a/examples/qvgviewer/main.cpp +++ b/examples/qvgviewer/main.cpp @@ -27,6 +27,7 @@ int main( int argc, char* argv[] ) focusIndicator->setObjectName( "FocusIndicator" ); MainWindow window; + window.setGraphic( ( argc > 1 ) ? argv[1] : ":/qvg/Tux.qvg" ); window.resize( 600, 400 ); window.addItem( focusIndicator ); window.show();