Qt learning Path"/>
Qt learning Path
3/23 油管上播放量过百万的QT C++初学者教程_哔哩哔哩_bilibili
在这里我们做的都是qt widget 支持GUI界面的应用程序。而qt console则是无GUI界面的,用于学习c/c++语言,有点像vscode的功能和界面
此段代码详解:
//每个Qt main() 都会包含的代码 与c++中int main(){ return 0;}类似#include <Qapplication>int main(int argc, char* argv[])
{Qapplication a(argc, argv); //a 可用任意字母串代替//填充代码return a.exec();
}//此段出现
fixed size 会让push bottom跟着整个窗口大小随之一起变化 //右键 布局
Buddy mode: 拖拽 编辑Tab:tab highlight 的部分
未出现的代码解析:
Q_OBJECT;
//本质是一个已定义好的宏,所有需要“信号+槽”功能的组建都必须用到这个
添加新文件:
鼠标右键添加新文件。default 到创建成功,将复制版的内容加到 最上方txt文件的 resource 中。新文件快捷方式出现。
push_bottom 转到槽 clicked:
在mainwindow.cpp中 include "dialog.h"//whatever is your page_name.h
hide(); 可加可加
课后作业: 把这个和之前学习的QApplication连接起来,做出点击后关闭的application。
LogIn 功能:如何获得外界的text 并验证
+gourp box(将userName part 和password part 整合,有利于将来整体大小调整)
第二个box增加了logIn后的跳转第二个window 很明显 第二个window你不用再去创造click and push bottom直接往下增添语句。在Login成功确认的MessageBox后直接跳转
增加图片
在主界面中创建label,把label中的文字删除,在main中敲这些代码。
Status Bar
直接在mainwindow.cpp里打就可以了。详情见上
效果
加入,5000 代表5s后提示消失
在main constructor 中加入以下则会
右下角出现progressBar
后一个数字用来调ratio 效果:
也可以的:
将logIn的密码更改为别人看不到的样式: 点击密码的LineEdit. 在property中更改
html: eg change the color of the fonts
html 任意代码可以带入
PushBottom change color or fonts.
Line Edit:
stylesheet 也可以增加背景图.
CheckBox
if you do this, the checkbox default is true.
choose one option: radio bottom; choose multiple option: check Box
if(ui->radioBottom->isChecked()){QMessageBox::information(this, "", "");} //放到pushbottom的槽里
Add same question radioBottom in a container like a vertical group. They will be able to answer different questions.
ToolBar item. You can also add icon to the toolBar item. You do not need to include QApplication.
ComboBox:
ui->comboBox->addItem(QIcon("the path"),"John");// path = icon path from resource file.
for(int i = 0; i < 10; i ++){
ui->comboBox->addItem(QIcon(" "), Qstring::number(i) + "name");}
在pushBt的槽里可以增加 QMessageBox::information(this, "title", ui->comboBox->currentText());
QMessageBox::information(this, "title", QString::number(ui->comboBox->currentIndex()));//点击pushBottom会出现。
ui->comboBox->insertItem(3, QIcon(\\path), "words")//在comboBox的第4个插入这个 3代表位置
QListWidget
更多推荐
Qt learning Path
发布评论