Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt设计器中QGraphicsView的占位符图像_Qt_Qt Designer_Qgraphicsview - Fatal编程技术网

Qt设计器中QGraphicsView的占位符图像

Qt设计器中QGraphicsView的占位符图像,qt,qt-designer,qgraphicsview,Qt,Qt Designer,Qgraphicsview,我经常有使用QGraphicsView的UI。在跑步时,我可以在我的场景中放置各种各样的精彩事物。然而,在Qt设计器(Creator)中的设计时,我希望显示某种占位符图像,以帮助我可视化UI的真实外观 我找不到用于设置某种背景图像的属性。我尝试了样式表属性中的各种设置,但没有显示任何内容,例如 QGraphicsView: { background-image: speedo.png; } 您可能只是使用了错误的语法: QGraphicsView{ 背景图像:url(“/path/to

我经常有使用QGraphicsView的UI。在跑步时,我可以在我的场景中放置各种各样的精彩事物。然而,在Qt设计器(Creator)中的设计时,我希望显示某种占位符图像,以帮助我可视化UI的真实外观

我找不到用于设置某种背景图像的属性。我尝试了样式表属性中的各种设置,但没有显示任何内容,例如

QGraphicsView: {
    background-image: speedo.png;
}

您可能只是使用了错误的语法:

QGraphicsView{
背景图像:url(“/path/to/your/image.png”);
}


是一个
QWidget
,因此您可以使用来设计具有允许属性的小部件

我无法在设计时或在预览模式下使用Windows中的背景图像在Qt Designer中显示背景图像。对于路径语法,我尝试了“file:///C:/Temp/speedo.png和“C:/Temp/speedo.png”。我还尝试将我的图像添加为资源文件,并使用url(:/rc/speedo.png)。@bfris它对我有效,你是否让
':“
QGraphicsView
之后?Arghh!我发现了问题。我的QGraphicsView太小,图像的一角是白色的。这个技巧可以缩放图像。但不能使用
背景图像
进行缩放。您必须使用
边框图像
。这是有效的:
QGraphicsView{border image:url(“C:/Temp/speedo.png”)0 0 0拉伸;}