|
1Qter豆
新建了2个类,form和widget。新建一个头文件,room.h。
room.h中申明变量
extern Form *f;extern Widget *wax;其他文件包含room.h。
main.cpp中定义
Widget *wax=new Widget(); Form *f=new Form(); wax->show(); f->show();
然后在按键的槽函数使用wax。
void Widget::on_xianshi_clicked(){ wax->show();}报错
error: undefined reference to `wax'
确认包含了头文件
#include "room.h"请问怎么回事哪?
room.h
#ifndef ROOM_H#define ROOM_H
#include "form.h"#include "widget.h"
extern Form *f;extern Widget *wax;
#endif // ROOM
main.cpp#include "room.h"#include <QApplication>
int main(int argc, char *argv[]){ QApplication a(argc, argv);
Widget *wax=new Widget(); Form *f=new Form(); wax->show(); f->show();
return a.exec();}
|
|