qt 공부중에 만난 undefined reference to `My virtual table 메

익명 사용자의 이미지

안녕하세요

qt 를 공부중에 아래와 같은 메시지를 만났습니다. 가상 테이블에 관련된 것 같은데
제가 c++ 도 같이 공부중이라 ... 도무지 모르겠습니다.
qt 소스를 첨부합니다. 감사합니다.

=========== 에러 메시지 ================
g++ -c -pipe -Wall -W -O2 -DNO_DEBUG -I/usr/local/qt/include -o main.o
main.cpp
main.cpp In function `int main (int, char **)'
main.cpp59 warning unused variable `My *my'
g++ -o main main.o -L/usr/local/qt/lib -L/usr/X11R6/lib -lqt -lXext -lX11 -lm
main.o In function `MyMy(void)'
main.o(.text+0x362) undefined reference to `My virtual table'
collect2 ld returned 1 exit status
make *** [main] 오류 1

1 #include
2 #include
3 #include
4 #include // for system();
5 #include
6
7 #define kor(str) QStringfromLocal8Bit(str) // 한글을 위해서....
8
9 class Widget public QWidget
10 {
11 public
12 Widget();
13 private
14 QLabel *label; // 레벨
15 QPushButton *quit; // 취소 버튼
16 QPushButton *ok; // ok 버튼
17 };
18
19 WidgetWidget()
20 {
21 label = new QLabel("Hnetconfig", this); // 제목 표시
22 label->setGeometry(50,10,200,50);
23
24 ok = new QPushButton("OK", this); // ok 버튼 표시
25 ok->setGeometry(80,350,70,30);
26
27 quit = new QPushButton("RESET", this); // 중지 버튼 표시
28 quit->setGeometry(150,350,70,30);
29
30 QObjectconnect(quit,SIGNAL(clicked()), qApp, SLOT(quit())); // 종료
슬롯
31 // QObjectconnect(ok,SIGNAL(clicked()), qApp, SLOT(Netrestart()));
32
33 resize(300,400);
34 }
35
36
37 // ok 버튼을 위한 시그널/슬롯 제작 ....
/// 문제의 발단이라고 생각되는 부분
// 이부분 빼면 잘 됩니다. 사실 예제 소스에 제 나름대로 함수 구현 할려고
// 이부분을 갖다 붙힌 거거든요 ^^;
38 class My public QObject
39 {
40 Q_OBJECT
41 public
42 My();
43 public slots
44 // void Netrestart();
45 };
46
47 MyMy()
48 {
49 }
50 /// 문제의 발단이라고 생각되는 부분끝

51 //void MyslotNetrestart()
52 //{
53 //}
54
55 int main(int argc, char **argv)
56 {
57 QApplication a(argc, argv);
58
59 My *my = new My;
60 Widget *widget = new Widget;
61
62 // QLabel label("Hnetconfig", widget);
63 // label.setGeometry(50,10,200,50);
64
65 a.setMainWidget(widget);
66 widget->show();
67
68 return a.exec();
69 }

cbycby의 이미지

Widget class에 Q_OBJECT 추가를 해주셔야 합니다.
Q_OBJECT는 QT의 signal/slot을 가능하게 해주는 것입니다.

http://www.korone.net QT 커뮤니티 사이트

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.