Qt中将控件放置在鼠标坐标指定位置

QLabel *m_tip_prompt = NULL;
m_tip_prompt=new QLabel;

QPoint aaa = cursor().pos();//获取鼠标位置
this->m_tip_prompt->setText(“测试”);
this->m_tip_prompt->raise();
this->m_tip_prompt->move(aaa.rx(), aaa.ry(),);
this->m_tip_prompt->adjustSize();//控件宽度根据text自适应
this->m_tip_prompt->setStyleSheet(“background-color:red;font:20px;”);//设置样式

猜你喜欢

转载自blog.csdn.net/xiao123456bin/article/details/89873926