[問題] qt 初始化畫面問題

看板C_and_CPP (C/C++)作者 (談無慾)時間9年前 (2017/04/25 19:39), 9年前編輯推噓1(107)
留言8則, 2人參與, 最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) win7 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) vs2015 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) qt5.7 問題(Question): 我需要等到讀到 usb上接的東西回傳序號之後才開始畫畫面 UART to USB 所以我在讀完序列號之後送出一個signal讓畫面初始化 connect(this,signal(getSN),this,slot(initView)); void myclass::initView(){ QPushButton *btn = new QPushbutton(this); ... ... }; 用debug模式下去看會跑進來initView這個slot 但畫面上完全看不到任何東西 不知道這有解嗎 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.169.79.56 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1493120346.A.5B0.html

04/25 21:05, , 1F
要看你的... ...是甚麼阿 沒初始化就沒初始化
04/25 21:05, 1F

04/25 21:08, , 2F
如果不用slot 單純在一開始的時候initView可以看得到畫
04/25 21:08, 2F

04/25 21:08, , 3F
04/25 21:08, 3F

04/25 21:15, , 4F
我覺得你連程式都寫錯
04/25 21:15, 4F


04/25 21:31, , 6F
我不知道你想用哪一條 但我覺得2,4要放destroyer
04/25 21:31, 6F

04/25 21:32, , 7F
或者是你想用QSignalMapper
04/25 21:32, 7F

04/25 21:32, , 8F
總之你的connect應該是給錯東西
04/25 21:32, 8F
後來發現是要用show()這個指令 東西就出來了 void myclass::initView(){ QPushButton *btn = new QPushbutton(this); btn->show(); }; 不在最上層畫畫面的時候 好像就要用show(); 不知道為什麼!? myClass::myClass(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); QPushButton *btn = new QPushbutton(this); } ※ 編輯: MOONY135 (59.124.46.66), 04/26/2017 11:02:23
文章代碼(AID): #1O_pLQMm (C_and_CPP)
文章代碼(AID): #1O_pLQMm (C_and_CPP)