我在两个文件中有两个不同的类:
class Game: public QGraphicsView()
class Window: public QMainWindow()
{
public: Window();
Game *game;
public slots: void test() {game = new Game();};
}
在Window.cpp中,我使用test()函数启动了一个新游戏:
Window::Window() {test();}
现在在Game.cpp中,我用两个QPushButton创建了一个QMessageBox
QMe
我有个小问题。我希望在MainWindow中从AnotherWindow运行函数。我不能为它设置connect()。
Main class: MainWindow
Other form: AnotherWindow
Function in main class: setVariable(QString)
Function in other form: btnClicked()
我现在连接了按钮信号clicked()
// In AnotherWindow.cpp
connect(ui->btnOK, SIGNAL(clicked()), this, SLOT(btnOkClicked()
我正在尝试在我的应用程序的状态栏上显示一些已连接/断开连接的消息。它是一个用c++编写的控制台应用程序,带有Qt。当连接状态发生变化时,连接处理程序调用回调(在某些GUI相关对象中),该回调将更新gui。我可以在我的QGraphicsScene上绘制,但是当我尝试使用QStatusBar的showMessage方法时,它有时会立即崩溃,有时它会工作,直到几次调用(但消息在超时后不会消失)。我收到这个错误消息:
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QStatu
在接收到信号后,我不得不调用对象的时隙(只需将信号转发到对方的对象时隙)。我知道我可以简单地实现插槽,从身体调用另一个插槽,但也许我可以用更简单的方式来实现它?
下面是示例代码:
class SomeWidget : public QObject
{
Q_OBJECT
signals:
textChanged(QString);
//...
};
//----------------------------------------------------------------------
class SomeController : public QObject