首页 > 代码库 > Qt 5 Designer使用一

Qt 5 Designer使用一

   

#ifndef DIALOG_H#define DIALOG_H#include <QDialog>namespace Ui {class Dialog;}class Dialog : public QDialog{    Q_OBJECTpublic:    explicit Dialog(QWidget *parent = 0);    ~Dialog();private slots:    void on_button_clicked();    void on_radiusLineEdit_textChanged();private:    Ui::Dialog *ui;};#endif // DIALOG_H
#include "dialog.h"#include "ui_dialog.h"#include <QPushButton>#include <QDialog>const static double PI = 3.1416;Dialog::Dialog(QWidget *parent) :    QDialog(parent),   ui(new Ui::Dialog){        ui->setupUi(this);        connect(ui->button, SIGNAL(Dialog::on_button_clicked), ui->areaLabel_2,            SLOT(Dialog::on_radiusLineEdit_textChanged));}Dialog::~Dialog(){    delete ui;}void Dialog::on_button_clicked(){    bool ok;    QString tempStr;    QString valueStr=ui->radiusLineEdit->text();    int valueInt=valueStr.toInt(&ok);    double area=valueInt*valueInt*PI;    ui->areaLabel_2->setText(tempStr.setNum(area));}void Dialog::on_radiusLineEdit_textChanged(){}

Qt 5 Designer使用一