qt初级错误:头文件中定义,cpp未实现
2015-12-13 22:59
337 查看
错误信息
问题
:-1: error: symbol(s) not found for architecture x86_64:-1: error: linker command failed with exit code 1 (use -v to see invocation)
编译输出
Undefined symbols for architecture x86_64:“MainWindow::slotQuestion()”, referenced from:
MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) in moc_mainwindow.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: * [Hello2.app/Contents/MacOS/Hello2] Error 1
22:39:31: 进程”/usr/bin/make”退出,退出代码 2 。
Error while building/deploying project Hello2 (kit: Desktop Qt 5.5.1 clang 64bit)
When executing step “Make”
原因
引起原因是头文件中定义的slot,在cpp中没有实现,导致编译错误代码
错误代码
mainwindow.h#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; private slots: void slotQuestion(); }; #endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle(tr("HelloQt")); connect(btn1,SIGNAL(clicked(bool)),this,SLOT(slotQuestion())); } MainWindow::~MainWindow() { delete ui; }
修改
只需在mainwindow.cpp中加上实现slot就ok了,void MainWindow::slotQuestion() { }
8147
相关文章推荐
- QTP使用问题集锦
- QT初级错误:继承于QMainwindow的窗口需调用setCentralWidget
- Qt学习之QTableView和QTableWidget的具体区别
- linux中内核、opencv、Qt各种软件版本查询
- QT图表绘制
- 自己重新实现QTP封装的一些常用的方法
- Qt中文乱码问题
- PyQt中QFileDialog记录上次打开目录(历史目录)的方法
- VS2010 + QT5.2+ QT-VS-Addin1.2.2开发环境配置
- Qt学习——qt文件信息的获取
- 《Qt 实战一二三》
- 《Qt 实战一二三》
- Qt标准对话框之QMessageBox
- Qt之国际化
- Qt之国际化
- qt程序中hid问题记录
- Windows系统下将Qt生成的应用程序打包成可以安装的文件setup***.exe
- Qt使用快捷键
- Qt 5.5 操作 Excel 的速度 效率问题
- Lesson6 how to use HTML QT Widgets