【发布时间】:2018-04-23 17:57:12
【问题描述】:
编辑:下面的解决方案
使用 Wt(版本 3)C++ 框架: 单击调用函数的 WPushButton 时:
button->clicked(boost::bind(&Service::burn, this));
如何以这样一种方式冻结屏幕(或所有按钮),在函数运行时(运行相当长的时间)什么都不能点击。目前,当Service::burn()函数运行时,我可以点击其他按钮在Service::burn()函数完成后排队执行。
请注意,所有按钮/屏幕都需要在冻结后恢复。还有一个功能:
解决方案:
Wt::WPushButton* spec_button;
void testclass::test_only()
{
spec_button = new Wt::WPushButton("slow func");
auto some_long_func = [&](){
cout << "#######start \n";
std::this_thread::sleep_for(std::chrono::seconds(1));
cout << "#######end \n";
spec_button->setDisabled(false);
};
content()->addWidget(spec_button);
spec_button->clicked().connect(spec_button, &WPushButton::disable);
spec_button->clicked().connect(boost::bind<void>(some_long_func));
}
【问题讨论】: