#include #include #include MainWindow::MainWindow(QWidget *parent) :..._qt string stra = ui->lineddita->text();">
当前位置:   article > 正文

QT设计常用控件_qt string stra = ui->lineddita->text();

qt string stra = ui->lineddita->text();

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QStringList>
#include <QCompleter>
#include <QMovie>

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

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

    //设置内容
    ui->lineEdit->setText("huangxingao");
    //设置显示方式
    //ui->lineEdit->setEchoMode(QLineEdit::Password);

    //设置边距
    ui->lineEdit->setTextMargins(15,0,0,0);
    //设置提示
    QStringList list;
    list<<"heoll"<<"haha"<<"How are you";
    QCompleter *com = new QCompleter(list,this);
    com->setCaseSensitivity(Qt::CaseInsensitive);//不区分大小写
    ui->lineEdit->setCompleter(com);

    //lable
    //设置内容
    ui->label_text->setText("黄贤高的图片");
    //设置图片
    ui->label_picture->setPixmap(QPixmap("://image/logo.jpg"));
    ui->label_picture->setScaledContents(true);//让图片适应lable大小
    //设置gif
    QMovie * mymovie = new QMovie("://image/gif.gif");//设置动画
    ui->label_gif->setMovie(mymovie);
    ui->label_gif->setScaledContents(true);
    mymovie->start();
    //设置url
    ui->label_url->setText("<h1><a href=\"https://www.baidu.com\">百度一下</a></h1>");
    ui->label_url->setOpenExternalLinks(true);

    //lCD
    ui->lcdNumber->display(124);

    //进度条
    ui->progressBar->setMinimum(0);
    ui->progressBar->setMaximum(100);
    ui->progressBar->setValue(50);
    
    //
}

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

//stackwidgets
void MainWindow::on_pushButton_3_clicked()
{
    static int i = 0;
    ui->stackedWidget->setCurrentIndex(++i%4);
}
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/225509
推荐阅读
相关标签