widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private slots:
void on_checkBox_clicked();
void on_checkBox_2_clicked();
void on_pushButton_clicked();
private:
Ui::Widget *ui;
};
#endif // WIDGET_H
widget.cpp
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget()
{
delete ui;
}
void Widget::on_checkBox_clicked()
{
if(ui->checkBox->isChecked())
{
ui->lineEdit->setReadOnly(true);
}
else
ui->lineEdit->setReadOnly(false);
}
void Widget::on_checkBox_2_clicked()
{
if(ui->checkBox_2->isChecked())
ui->lineEdit->setEchoMode(QLineEdit::Password);
else
ui->lineEdit->setEchoMode(QLineEdit::Normal);
}
void Widget::on_pushButton_clicked()
{
ui->label->setText(ui->lineEdit->text());
}
main.cpp
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}