Skip to content

Commit 2569e0a

Browse files
Dynamically created image viewer now loads random image in demo
1 parent be86a77 commit 2569e0a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

demo/MainWindow.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include <QToolButton>
6161
#include <QToolBar>
6262
#include <QPointer>
63+
#include <QRandomGenerator>
6364

6465

6566
#ifdef Q_OS_WIN
@@ -325,7 +326,19 @@ struct MainWindowPrivate
325326
{
326327
static int ImageViewerCount = 0;
327328
auto w = new CImageViewer();
328-
auto Result = w->loadFile(":adsdemo/images/ads_logo.svg");
329+
auto ImageIndex = QRandomGenerator::global()->bounded(4);
330+
auto FileName = ":adsdemo/images/ads_logo.svg";
331+
332+
// Pick a random image from a number of images
333+
switch (ImageIndex)
334+
{
335+
case 0: FileName = ":adsdemo/images/ads_tile_blue.svg"; break;
336+
case 1: FileName = ":adsdemo/images/ads_tile_light_blue.svg"; break;
337+
case 2: FileName = ":adsdemo/images/ads_tile_green.svg"; break;
338+
case 3: FileName = ":adsdemo/images/ads_tile_orange.svg"; break;
339+
}
340+
341+
auto Result = w->loadFile(FileName);
329342
qDebug() << "loadFile result: " << Result;
330343
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
331344
DockWidget->setWidget(w,ads:: CDockWidget::ForceNoScrollArea);
@@ -701,6 +714,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
701714

702715
// uncomment if you would like to enable dock widget auto hiding
703716
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
717+
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideShowOnMouseOver, true);
704718

705719
// uncomment if you would like to enable an equal distribution of the
706720
// available size of a splitter to all contained dock widgets

0 commit comments

Comments
 (0)