问题1:在利用VS2013+Qt5.9.4时有点懵,用Qt creator还知道点。VS中明明在ui界面中添加了控件,在代码中却看不到相关控件的变量。
上网百度后,看到别人写的:
1.更改UI界面后,保存UI界面;
2.返回VS中,找到UI界面文件,右击->编译;
3.再选中解决方案,右击->重新扫描解决方案。
发现确实有用。
问题2:在自定义函数中直接通过ui找不到相对应的控件变量。
后来发现必须先通过this指针索引:
ImageProcess::ImageProcess(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
//在构造函数中,可以通过ui直接引用
connect(ui.pushButton_LoadImage, SIGNAL(clicked()), this, SLOT(ShowImage()));
}
void ImageProcess::ShowImage()
{
//在自定义函数中,必须通过this->ui引用
this->ui.label->clear();
}