转到槽的方法:
常用控件

先放置上图那个东西,在不同页放不同控件,下图切换是一个按钮属性

常用控件
常用控件
转到槽后直接在程序里面写按钮按下后的代码,下面第二个图,第一个图自动生成,固定格式on-“上图改的名字”-连接槽的方式
常用控件

常用控件

熟悉各种控件就要把每个控件都放一下

常用控件

常用控件
常用控件

常用控件
常用控件
常用控件
常用控件 

注意:如果要查看某个含有形参的函数,要先给它补偿,即随便赋个实参,再按F1
常用控件
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include<QCompleter>//设置提示字符的模型
#include<QStringList>//字符串列表

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    ui->myButton->setText("456");

    //QLineEdit
    QString str = ui->lineEdit->text();//获取内容
    qDebug() << str;

    //设置内容
    ui->lineEdit->setText("12345678");

    //设置内容显示距离上下左右的间隙
    ui->lineEdit->setTextMargins(15,0,0,0);//左面空出15个像素点

    //设置内容显示方式
   // ui->lineEdit->setEchoMode(QLineEdit::Password);//密码模式

    QStringList list;
    list << "hello" << "How are you" << "haha";

    QCompleter *com = new QCompleter(list,this);
    com->setCaseSensitivity(Qt::CaseInsensitive);//Qt::CaseInsensitive不区分大小写

    ui->lineEdit->setCompleter(com);//把模型给谁用,前提是把密码模式注释掉,要不然不显示



}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_change_clicked()
{

    static int i = 0;
    ui->stackedWidget->setCurrentIndex( ++i % 4 );
}

相关文章:

  • 2021-05-04
  • 2021-05-04
  • 2021-06-18
猜你喜欢
  • 2021-12-10
  • 2022-12-23
  • 2021-11-17
  • 2021-10-11
相关资源
相似解决方案