我有2个停靠小部件,其中dock1拥有整个应用程序。在哪里我可以放大。我想在dock2中的相同应用程序的副本,它适合屏幕。我试图添加一个Qgraphicscene到dock2加载dock1应用程序。 没有得到预期的产出。
void MainWindow::createDockWindows()
{
win = new QWidget;
QToolBar *tool = new QToolBar;
QGraphicsView view;
QHBoxLayout *layout = new QHBoxLayout;
minimize = new QToolButton(this);
pix = style()->standardPixmap(QStyle::SP_TitleBarMinButton);
minimize->setIcon(pix);
tool->addWidget(minimize);
tool->addWidget(close);
layout->addWidget(tool);
layout->setMargin(0);
layout->setAlignment(Qt::AlignRight);
win->setLayout(layout);
connect(close,SIGNAL(clicked()),this,SLOT(close_window1()));
connect(minimize,SIGNAL(clicked()),this,SLOT(minimize_window1()));
dock1 = new QDockWidget(tr("window 1"), this);
dock1->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
app1 = new QWidget(dock1);
dock1->setMinimumHeight(200);
dock1->setMinimumWidth(200);
dock1->setTitleBarWidget(win);
view1 =new QQuickView();
app1 = QWidget::createWindowContainer(view1, this);
app1->setFocusPolicy(Qt::TabFocus);
view1->setSource(QUrl::fromLocalFile("app1.qml"));
dock1->setWidget(app1);
addDockWidget(Qt::RightDockWidgetArea, dock1);
viewMenu->addAction(dock1->toggleViewAction());
dock2 = new QDockWidget(tr("window 2"), this);
dock2->setMinimumHeight(200);
dock2->setAllowedAreas(Qt::BottomDockWidgetArea | Qt::RightDockWidgetArea);
app2 = new QWidget(dock2);
QGraphicsScene* Scene = new QGraphicsScene(this);
view.setScene(Scene);
QGraphicsProxyWidget *proxy = Scene->addWidget(app1);
view.setDragMode(QGraphicsView::ScrollHandDrag);
//QGraphicsProxyWidget* proxyWidget = scene.addWidget(app1);
//proxyWidget->setFlag(QGraphicsItem::ItemIgnoresTransformations);
// view2 =new QQuickView();
// app2 = QWidget::createWindowContainer(view2, this);
// app2->setFocusPolicy(Qt::TabFocus);
// view2->setSource(QUrl::fromLocalFile("app2.qml"));
dock2->setWidget(app2);
addDockWidget(Qt::BottomDockWidgetArea, dock2);
viewMenu->addAction(dock2->toggleViewAction());
}
我收到错误说
QGraphicsProxyWidget::setWidget: cannot embed widget 0x1264fff0 which is not a toplevel widget, and is not a child of an embedded widget
如何在dock2中显示dock1应用程序的副本并使app1适合dock2屏幕。总体而言,我希望dock1为缩放视图,dock2将缩小同一应用程序的视图。我正在尝试实现缩放和平移。