簡體   English   中英

Qt將Widget添加到GraphicsView?

[英]Qt add Widget to GraphicsView?

有沒有辦法在QGraphicsView上繪制Widgets而不是QGraphicsScene,以便在移動場景時窗口小部件保持原位?

我想創建一些可以在工作區內停靠的對話框,如下所示:

在此輸入圖像描述 http://www.thebandfrom.com/wp-content/uploads/photoshop-ui.png

您可以使用QGraphicsSceneaddWidget函數,然后將QGraphicsItem::ItemIgnoresTransformations標志設置為添加的QGraphicsProxyWidget

QGraphicsProxyWidget* proxyWidget = scene->addWidget(myWidget);
proxyWidget->setFlag(QGraphicsItem::ItemIgnoresTransformations);

您可以通過將QGraphicsView設置為其父級來直接將小部件添加到QGraphicsView 您還可以添加布局,以便在調整QGraphicsView的大小時,您的小部件可以自行安排。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM