如何在静态方法中与QPushButton交互
how to interact with QPushButton in a static Method
我有2个按钮的弹出窗口,当我使用
时,我想在静态方法中使用这些按钮的SIGNAL和SLOTconnect(allbox->getAcceptButton(),SIGNAL(clicked()),this,SLOT(dosmt());
程序崩溃了。我知道怎么解决这个问题吗?谢谢你的帮助
你必须写一个插槽调用静态方法
您已经问了一个类似的问题,答案是相同的:您不能在静态方法中使用this
,因此您将不得不传递一个具有dosmt()
插槽的对象。
class Test: public QObject
{
Q_OBJECT
...
public:
static void testMethod();
public slots:
void testSlot();
};
Test::Test()
{
QObject::connect(button, SIGNAL(clicked(), this, SLOT(testSlot()));
}
Test::testSlot()
{
Test::testMethod();
}
只是一个简短的例子,你必须连接一个信号与插槽,因为它是由Qt文档http://doc.qt.digia.com/qt/signalsandslots.html
相关文章:
- Qt VTK交互风格的信号到小部件
- Qt Quick-如何仅从c++代码与qml属性交互
- 复制和交换习惯用法与移动操作之间的交互
- 为什么在访问 vtkRenderWindow 的"交互器"变量时会发生段错误?
- Qt QGraphicsProxyWidget 与 QGraphicsScene 的交互
- 在单击 QPushButton 时调用带有参数的函数
- 按下 QPushbutton 时将文本保存到文件
- 使用 Python 事件并与 C++ 交互
- QProcess无法通过QPushButton执行终端线路命令
- 函数-本地枚举声明和 ADL 的交互
- 如何在扩展的QQuickItem中与模型交互
- 寻找C++中数组和cout交互的解决方案
- C++继承和"常量"交互的问题
- 在两个类之间连接QPushButton
- 以太坊与外部 c++ 库的交互稳定性
- 玩家移动和碰撞之间的交互问题
- C++ 和 Lua 函数之间的交互与 3D 矢量参数
- 内存分配究竟是如何发生的,Java和C如何交互以跟踪同一对象?
- 如何包装对象,使它们成为无法交互的单独类型?
- 如何在静态方法中与QPushButton交互