如何将阴影效果应用于QGraphicsItem
How to apply a drop shadow effect to QGraphicsItem?
我是QT的新手,我想为我的QGraphicsRectItem画阴影,但它似乎不起作用我在QGraphicsScene 中使用以下代码
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);
QGraphicsDropShadowEffect * effect = new QGraphicsDropShadowEffect();
effect->setBlurRadius(50);
QGraphicsRectItem * item = new QGraphicsRectItem(100,100,50,50);
item->setBrush(QBrush(Qt::cyan));
item->setGraphicsEffect(effect);
scene->addItem(item);
然而,如果我把它应用到我的图形中,这很好。像这个一样查看
ui->graphicsView->setGraphicsEffect(effect);
我做错了什么?
可能您在本地创建了效果,并且该指针被擦除,因此将效应的声明移动到头文件中。
相关文章:
- 使用 fopen 打开 .pak 文件并使该文件应用于 const 无符号字符* (C++)
- 使用 std::应用于 std::bind
- 如何将Affine3d应用于Vector3d
- 运算符 += 应用于 std::valarray<int*>
- 函数可以应用于 std::optional,并返回一个可选值吗?
- 为什么带有类型参数的运算符 () 可以应用于 result_of 上下文中的类型?
- 当正斜杠运算符应用于C++中的字符串类型时,它会做什么
- 将MFPKEY_ASFMEDIASINK_AUTOADJUST_BITRATE应用于IMFSinkWriter
- (C++)(Visual Studio) 将高斯模糊滤镜应用于 RGB 中的灰度图像
- 在运行时将更改的环境变量应用于 QApplication
- Strcmp 类行为应用于C++中的对象列表
- 如何将 ItemDelegate 设置为仅应用于 QTreeView 中的父列
- 什么是应用于C 和CMAKE的定义
- 将对象方法从向量应用于C 的第二个向量中的对象
- STL:将功能应用于Adchacent_difference的结果,而无需额外的容器
- WXWIDGETS应用于WXStaticBitMap时,屏幕截图将大部分图像留为空白
- 如何将垂直纹理应用于QT Surface3D
- 如何将[[nodiscard]]属性应用于lambda
- 奇怪的语法构造 - 应用于 typedef 的运算符 () 使用 VS2015 成功编译
- 将 QPropertyAnimation 应用于 QRect