Qt interface class
Qt interface class
我想使用这样一个main:
int main()
{
if (param)
QtDisp *disp = new QtDisp(); //no visual result
else
SDLDisp *disp = new SDLDisp();
disp->init(param); //displays the window
while (1)
{
disp->change_color(colour); //change background colour
sleep(1);
}
}
它与SDLDisp一起工作,现在我必须创建QtDisp。
我不知道如何处理阻塞的exec()。首先,我想使用Qthread,但显示必须在第一个线程中。
Qt是基于事件的驱动框架。没有事件循环,所有gui部分都无法工作。除了另一个线程中的暴力计算之外,几乎所有的事情都需要在事件循环中完成。Exec()方法启动该事件系统。因此,在调用exec()之前,您将无法做一些有用的事情。最简单的方法是这样做:
int delay = 10; //msec
QTimer *colorChangeTimer() = new QTimer();
colorChangeTimer->setSingleshot(false);
connect(colorChageTimer, SIGNAL(timeout()), disp, SLOT(onTimerChageColor()));
colorChageTimer->start(delay);
int result = QApplication::exec();
delete colorChangeTimer;
return result;
相关文章:
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 使用模板进行堆栈实现; "name followed by :: must be a class or namespace"
- "Undefined class"作为is_base_of的论据
- 如何将class.cpp和class.hpp编译为一个.o文件
- Android NDK 编译 LAME HAVE_MPGLIB > 'interface.h' 文件未找到
- 重载 -> shared_ptr 个实例中的箭头运算符<interface>,接口中没有纯虚拟析构函数
- '{'标记之前的预期类名,然后在预声明时无效使用不完整的类型'class class_name'
- 如何使用"derived input class"创建派生类?
- 错误:"Left of getValue must have class/struct/union"
- ' class a : b ' 和 ' class a : public b ' 之间的继承类不同
- Pybind11 Class Definition
- 在C++中使用没有合作伙伴Class/Cpp文件的头文件是否实用
- C2011 'CMemDC':Visual Studio 2019中的'class'类型重新定义
- TypeError: [c++ addon class] 不是构造函数
- C++ class template
- 当初始值设定项是基类名时'initializer does not name a non-static data member or base class'错误
- Clearing Class Foo with new(pFoo) Foo()
- 如何使用带有Qt和C++的"Interface Class"进行通信
- Qt interface class