Qt学习笔记(其他控件)

这篇博客介绍了Qt中的一些关键控件的使用,包括Group Box作为分组布局,Scroll Area在空间不足时提供滚动条,ToolBox实现类似QQ分组的功能,以及Tab Widget、Stacked Widget的切换效果。还详细讲解了ComboBox、LineEdit、TextEdit、QLabel的各种特性和应用场景,如密码输入、文本编辑和图像显示,并提及了如何设置控件的焦点。
摘要由CSDN通过智能技术生成

group box 一个分组布局 用于加入多个控件
Scroll Area 控件用于放入多个控件,地方不够大了会有滚动条
toolbox  和QQ 里的分组很像,家人 朋友等等。
修改内容 currentIndex下的 currentltemText
tab widget标签页的切换 网页中的百度 新浪等等
Stacked widget 栈创空,栈容器
stacked 中的小黑箭头是方便设计的,在运行的时候是没有的。
在设计的情况下才有,方便设计
相当于 整个看到的东西 真个栈都换掉了
放三个按钮,按第一个按钮,切换一个栈,按第二个按钮,切换一个栈

combo box 下拉框

font Combo Box看Word文档字体有什么  这里就有什么
line Edit 行编辑
QLine Edit选项下有 echoMode属性  Normal是什么都看不见
password是密文遮挡
passwordEdit 输入时没哟遮挡,光标放在其他地方才有遮挡

Text Edit是文本编辑框   Plain Text edit是纯文本编辑框
text edit 可以加粗字体颜色等辅助设置    后者是纯文本

QLable 不仅可以显示文字还可以显示图片
QLable 还可以显示动图


ui->lineEdit->setFocus();
//设置光标焦点
光标定位在哪里


 

#-------------------------------------------------
#
# Project created by QtCreator 2019-08-16T22:28:40
#
#-------------------------------------------------

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = 08_Control_Other
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        mainwindow.cpp

HEADERS += \
        mainwindow.h

FORMS += \
        mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
    res.qrc
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H
#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMovie>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //设置默认选中第零项
    ui->stackedWidget->setCurrentIndex(0);
  //想要显示全部则添加布局

    //stackWidget
    connect(ui->btn1,&QPushButton::clicked,this,[=](){
       //
       ui->stackedWidget->setCurrentIndex(0);

    });

    connect(ui->btn3,&QPushButton::clicked,this,[=](){
       //
       ui->stackedWidget->setCurrentIndex(2);

    });
    connect(ui->btn2,&QPushButton::clicked,this,[=](){
       //
       ui->stackedWidget->setCurrentIndex(1);
    });
//用索引控制翻页





    //下拉框的使用
    ui->comboBox->addItem("奔驰");
      ui-
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值