在QGraphicsView中如何显示QGraphicsTextItem对象

weixin_38056491 2019-09-19 07:04:03
我想在我的QGraphicsView 中某一坐标点处显示我的文本对象QGraphicsTextItem,代码如下:QGraphicsView *graphicsView= new QGraphicsView(InputParamDialogClass);...//QGraphicsView 的初始化代码QGraphicsScene scene;QGraphicsTextItem  strtext1(tr("testtext"));QPoint temp(50,50);strtext1.setPos(temp);QFont *myfont=new QFont();strtext1.setFont(*myfont);strtext1.setTextWidth(20);strtext1.setDefaultTextColor(QColor(100,100,100,0.5));scene.addItem(&strtext1);graphicsView->setScene(&scene);graphicsView->show();但是以上代码不能实现该功能:压根无文本显示,请问问题出在哪?
...全文
21 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

435

社区成员

发帖
与我相关
我的任务
社区描述
其他技术讨论专区
其他 技术论坛(原bbs)
社区管理员
  • 其他技术讨论专区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧