(QT學習筆記) QPushButton使用介紹

2021-10-12 06:20:56 字數 2518 閱讀 5810

qpushbutton使用介紹

【qpushbutton參考文件】

【建立按鈕並顯示】

//按鈕

qpushbutton * btn = new qpushbutton;

btn->show(); //show用頂層方式彈出

void setparent(qwidget *parent)
btn->setparent(this);

【按鈕上顯示文字】

// qabstractbutton class

void settext(const qstring &text)

btn->settext("喜羊羊");  //進行了隱式型別轉換,轉成qstring

【建立第二個按鈕,會覆蓋第乙個】

//qpushbutton class

qpushbutton(const qstring &text, qwidget *parent = nullptr)

qpushbutton *btn2 = new qpushbutton("灰太狼",this);

【移動第二個按鈕】

【重置視窗、按鈕大小】

【指定視窗標題】

//qwidget class   public slots

void setwindowtitle(const qstring &)

this->setwindowtitle("第乙個視窗");

【設定視窗固定大小】

//qwidget class

void setfixedheight(int h)

void setfixedsize(const qsize &s)

void setfixedsize(int w, int h)

void setfixedwidth(int w)

this->setfixedsize(600,400);
【小結】

qt自定義控制項樣式04 QPushButton

注釋只為解釋,qss語法並不能直接這樣寫,美化控制項時,下面的所有選項並不需要全部進行設定,自行選擇qpushbutton qpushbutton pushbutton pressed 滑鼠按下時的效果 qpushbutton flat 按鈕樣式 qpushbutton open 當按鈕開啟選單時 ...

Qt學習筆記

1.參考資料 1 2 3 4 5 6 2.faq 2.1.qt creator 2.1.1.xp下用qt creator編譯自帶例子mdi sdi 當不勾選projects build settings build environment的 clear system environment 時,編譯...

QT學習筆記

1.在windows下配置好qt的環境變數以後,用cmd開始編譯,qmake project qmake hello.pro mingw32 make 結果出現錯誤 include 問題已經解決了,主要是 故而只需在.pro檔案中加入 greaterthan qt major version,4 q...