mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Dynamically created image viewer now loads random image in demo
This commit is contained in:
parent
be86a772ce
commit
2569e0aa05
@ -60,6 +60,7 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -325,7 +326,19 @@ struct MainWindowPrivate
|
|||||||
{
|
{
|
||||||
static int ImageViewerCount = 0;
|
static int ImageViewerCount = 0;
|
||||||
auto w = new CImageViewer();
|
auto w = new CImageViewer();
|
||||||
auto Result = w->loadFile(":adsdemo/images/ads_logo.svg");
|
auto ImageIndex = QRandomGenerator::global()->bounded(4);
|
||||||
|
auto FileName = ":adsdemo/images/ads_logo.svg";
|
||||||
|
|
||||||
|
// Pick a random image from a number of images
|
||||||
|
switch (ImageIndex)
|
||||||
|
{
|
||||||
|
case 0: FileName = ":adsdemo/images/ads_tile_blue.svg"; break;
|
||||||
|
case 1: FileName = ":adsdemo/images/ads_tile_light_blue.svg"; break;
|
||||||
|
case 2: FileName = ":adsdemo/images/ads_tile_green.svg"; break;
|
||||||
|
case 3: FileName = ":adsdemo/images/ads_tile_orange.svg"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Result = w->loadFile(FileName);
|
||||||
qDebug() << "loadFile result: " << Result;
|
qDebug() << "loadFile result: " << Result;
|
||||||
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
|
ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Image Viewer %1").arg(ImageViewerCount++));
|
||||||
DockWidget->setWidget(w,ads:: CDockWidget::ForceNoScrollArea);
|
DockWidget->setWidget(w,ads:: CDockWidget::ForceNoScrollArea);
|
||||||
@ -701,6 +714,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
// uncomment if you would like to enable dock widget auto hiding
|
// uncomment if you would like to enable dock widget auto hiding
|
||||||
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig);
|
||||||
|
CDockManager::setAutoHideConfigFlag(CDockManager::AutoHideShowOnMouseOver, true);
|
||||||
|
|
||||||
// uncomment if you would like to enable an equal distribution of the
|
// uncomment if you would like to enable an equal distribution of the
|
||||||
// available size of a splitter to all contained dock widgets
|
// available size of a splitter to all contained dock widgets
|
||||||
|
Loading…
Reference in New Issue
Block a user