Re: [問題] QT DESIGER產生CODE的地方

看板C_and_CPP (C/C++)作者 (談無慾)時間9年前 (2016/09/27 10:59), 9年前編輯推噓3(303)
留言6則, 4人參與, 最新討論串3/3 (看更多)
※ 引述《Serge45 (QAQ)》之銘言: : ※ 引述《MOONY135 (談無慾)》之銘言: : : 開發平台(Platform): (Ex: VC++, GCC, Linux, ...) : : VS 2015 C++ : : 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) : : QT 5.7 : : 問題(Question): : : 小弟剛從C#過來 抱歉再問一個問題 vs中 如果是使用QT去拉畫面 在ui_mainwindow.h 如果有一個pushButton 那就會出現下列的code pushButton = new QPushButton(centralWidget); pushButton->setObjectName(QStringLiteral("pushButton")); pushButton->setGeometry(QRect(80, 150, 93, 28)); 但如果是手工打造的話 通常還要自己加slot 然後必須要寫connect connect(pushBotton1, SIGNAL(clicked()), this, SLOT(changeCheckBox())); 但我好像找不到他的connect寫在哪... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.246.226 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1474945189.A.445.html

09/27 13:23, , 1F
QObject::connect
09/27 13:23, 1F
我的意思是...如果是用 VS 的QT DESIGN 只要把QPUSHBUTTON拉上去UI 好像就會自動CONNECT on_button_click()這個事件... 我是看了這篇 http://blog.csdn.net/tengweitw/article/details/21275721 然後照她說的在兩個窗口設計完按鈕之後 我應該會在ui_mydialog.h裡面看到 pushButton的生成 QPushButton *pushButton; pushButton = new QPushButton(Form); pushButton->setObjectName(QStringLiteral("pushButton")); pushButton->setGeometry(QRect(100, 140, 93, 28)); 但沒有看到有去CONNECT on_pushButton_clicked()這個方法... ※ 編輯: MOONY135 (1.169.75.197), 09/27/2016 19:39:25

09/28 21:41, , 2F
QMetaObject::connectSlotsByName
09/28 21:41, 2F

09/29 22:56, , 3F
09/29 22:56, 3F

09/29 22:57, , 4F
這種on_<WidgetName>_<SignalName>是特殊慣例用法
09/29 22:57, 4F

09/30 08:45, , 5F
原來如此...因為之前寫C#是要在自己加事件...
09/30 08:45, 5F

09/30 13:46, , 6F
自己CONNECT也行 我自己本身很少用這種特殊用法
09/30 13:46, 6F
文章代碼(AID): #1NwU2bH5 (C_and_CPP)
文章代碼(AID): #1NwU2bH5 (C_and_CPP)