日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

qt初学者 第一个小程序 小界面

發布時間:2025/3/19 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 qt初学者 第一个小程序 小界面 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//標簽 \ q push button \ 文本編輯框 || qmake -project 生成工程文件 (.pro ? ?對工程文件修改 最后加上 QT += widgets gui || qmake || mingw32-make #include <QApplication>#include <QLabel> #include <QLineEdit> #include <QPushButton>#include <QHBoxLayout>#include <QVBoxLayout>#include <QWidget>int main(int argc , char *argv[]) {QApplication app(argc,argv);?? ??? ?//創建一個程序對象QLabel *infoLabel = new QLabel;QLabel *openLabel = new QLabel;QLineEdit *cmdQLineEdit = new QLineEdit;QPushButton *commitbutton = new QPushButton;QPushButton *cancelbutton = new QPushButton;QPushButton *browsebutton = new QPushButton;infoLabel->setText("please input message :");openLabel->setText("open ");cmdQLineEdit->clear();commitbutton->setText("commit");cancelbutton->setText("cancel");browsebutton->setText("browse");QHBoxLayout *cmdQHBoxLayout = new QHBoxLayout;cmdQHBoxLayout->addWidget(openLabel);cmdQHBoxLayout->addWidget(cmdQLineEdit);QHBoxLayout *buttonQHBoxLayout = new QHBoxLayout;buttonQHBoxLayout->addWidget(commitbutton);buttonQHBoxLayout->addWidget(cancelbutton);buttonQHBoxLayout->addWidget(browsebutton);QVBoxLayout *mainQVBoxLayout = new QVBoxLayout;mainQVBoxLayout->addWidget(infoLabel);mainQVBoxLayout->addLayout(cmdQHBoxLayout);mainQVBoxLayout->addLayout(buttonQHBoxLayout);QWidget *w = new QWidget;w->setLayout(mainQVBoxLayout);w->show();return app.exec();?? ??? ??? ?//不能讓程序死了 死循環 }

1.1打開qt

1.2進入你創建的qt工程文件目錄

1.3生成工程文件

1.3.1打開生成的工程文件 最后加上QT += widgets gui

1.4編譯

1.5生成執行文件

1.6找到QT安裝目錄下的bin文件在路徑上面點擊復制路徑

1.7我的電腦 右擊屬性 高級設置 環境變量 找到path 編輯 添加剛剛的路徑

1.8 運行你的小程序吧
?

?

1.9注意事項

注意你的.cpp文件名要和你創建的 文件夾的名字保持一致 不然編譯會報錯的

總結

以上是生活随笔為你收集整理的qt初学者 第一个小程序 小界面的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。