0

我正在尝试为我的 Gui 应用程序创建一个日志窗口。

我有名为 sql 和 MyService 的类

如何从类 sql 构建和发出信号以更新 MyService 日志窗口?

在 main.cpp 中:

    MyService myService;
    sql mySql;
    QObject::connect(mySql, SIGNAL(updateMyLog(QString(msg))),myService, 
    SLOT(updateMyLog(QString(msg))));

编辑:
我在我的 sql 类中忘记了 Q_OBJECT 并且错误 dosnt 不再显示

error: C2665: 'QObject::connect' : 
none of the 3 overloads could convert all the argument types

EDIT2:
我的 updateMyLog 插槽是:

public slots:
void updateMyLog(QString logmessage);

我得到不同的错误:

QObject::connect: No such signal sql::updateMyLog(QString msg)
4

2 回答 2

0

its seems i should do this:

QObject::connect(&mySql, SIGNAL(updateMyLog(QString)),&myService,
                 SLOT(updateMyLog(QString)));
于 2012-11-25T18:21:24.313 回答
0

Does it work if you write it like this?

QObject::connect(&mySql, SIGNAL(updateMyLog(QString)), &myService, 
SLOT(updateMyLog(QString)));

Please note that you should pass pointers as the first and third parameters. As myService is not a pointer, you should get the memory address where it is allocated (a pointer to it).

于 2012-11-25T18:23:08.970 回答