[問題] 一些關於QT SLOT 的問題

看板C_and_CPP (C/C++)作者 (yoga)時間16年前 (2009/08/14 13:40), 編輯推噓2(206)
留言8則, 4人參與, 最新討論串1/1
在我的calculator.cpp檔案裡有這段程式 connect(c1,SIGNAL(clicked()),this,SLOT(getinfo1())); c1是我已經宣告並allocate的指標 getinfo1()是我寫好的SLOT函數 如下: void calculator::getinfo1(){ first=first*10+1; text->setText(QString::number(first)); text->setText(text->text()+QString::number(first)); times=times+1}; 函數的程式碼不是我要問的重點,我的問題是我寫好之後去compile, 可以過,也可以RUN,但有waring,導致我的SLOT根本沒作用。他說: Object::connect: No such slot QWidget::getinfo1() 我的calculator.h檔的宣告如下: class calculator:public QWidget{ public slots: void getinfo1(); ..... ..... .... .. . 我百思不得其解,希望各位QT高手幫我解惑。不知道我該怎麼改,改哪裡,或是 那個waring代表甚麼意思。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.87.215

08/14 13:53, , 1F
.h 要加上 Q_OBJECT 這個 macro, 再重新qmake一次
08/14 13:53, 1F

08/14 14:49, , 2F
加在 class 定義的開頭。
08/14 14:49, 2F

08/14 14:58, , 3F
甚麼叫qmake
08/14 14:58, 3F

08/14 15:50, , 4F
你用什麼東西編譯你的程式?
08/14 15:50, 4F

08/14 17:56, , 5F
VS
08/14 17:56, 5F

08/14 17:56, , 6F
喔我知道了,qmake就是QT的compiler
08/14 17:56, 6F

08/14 18:18, , 7F
qmake不是compiler,他是一個用來產生vs專案檔或makefile
08/14 18:18, 7F

08/14 18:19, , 8F
的工具
08/14 18:19, 8F
文章代碼(AID): #1AXFYygm (C_and_CPP)
文章代碼(AID): #1AXFYygm (C_and_CPP)