+ QT + UI interface and the interface acquaintance editing area operate in conjunction

When the acquaintance UI interface image to learn the interface components are doing:

 

 

Once you have the interface, allowing developers QT's become more convenient, but sometimes can not meet the ui interface function, you need to use the code to solve, how to use code?

First: Open the editing area;

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);//此处的代码就是刚才在ui里面所有的操作,我们在以后的编程中涉及到添加代码的时候,应该将代码放在这句话之后,
                      //不然刚才在ui中的操作容易出现错误

    //利用代码改变按钮上的内容,
    ui->Button->setText("123");

    /*此处的重点是在对控件操作的时候,多出了ui,即应该指明是ui里面的控件
    */
}

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

 

Guess you like

Origin www.cnblogs.com/doker/p/11032016.html