c++ - Qt connect函式報錯?
高洛峰
高洛峰 2017-06-19 09:07:26
0
2
1291

#include <QObject>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "addDialog.h"
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{

ui->setupUi(this);
setFixedSize(this->width(), this->height());
addDialog addD();
editDialog editD();
QObject::connect(&editD, &editDialog::sendData,
                 this, &MainWindow::get_data_from_edit);
    QObject::connect(&addD, &addDialog::sendData,
                     this, &MainWindow::get_data_from_add);
}

兩個connect都報錯誤

error: no matching function for call to 'MainWindow::connect(editDialog (*)(), void (editDialog::*)(QString), MainWindow*, void (MainWindow::*)(QString))'
                      this, &MainWindow::get_data_from_edit);
                                                           ^
In file included from D:\QT.9\mingw53_32\include\QtCore/QObject:1:0,
                 from mainwindow.cpp:3:

error: no type named 'type' in 'struct std::enable_if<false, QMetaObject::Connection>'

所使用類別均繼承QObject並包含Q_OBJECT

使用舊語法仍然報錯

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回覆(2)
漂亮男人

addDialog addD();
editDialog editD();
這兩句是實例2個物件嘛?把()去掉試試。

某草草

樓主,你把MainWindow::get_data_from_edit和MainWindow::get_data_from_add的方法宣告貼出來。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!