[英]How do I modify a QLabel object in my UI outside of its slot?
只是一个简短的问题:
我希望根据其窗口小部件无关的条件语句的值来编辑QLabel对象超出其插槽的文本。 在线研究尚无定论,因此,如果您能澄清这一点,我将不胜感激。
谢谢!
编辑:我使用Qt Designer将QLabel放入MainWindow类中,这意味着它从未在MainWindow.cpp源代码中正式声明过。 这是代码说明:
if (webcam.isOpened() == false)
{
MainWindow::mainVideo.setText("Stream is offline.")
/*mainVideo is my QLabel, I need to figure out how to access this if
*it was placed into my UI via Qt Designer.
*/
}
必须使用:
if(condition){yourlabel.setText(your text);}
在您的情况下:
if (!webcam.isOpened())
{
ui->mainVideo->setText("Stream is offline.")
/*mainVideo is my QLabel, I need to figure out how to access this if
*it was placed into my UI via Qt Designer.
*/
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.