发布网友 发布时间:2023-07-18 05:13
共1个回答
热心网友 时间:2024-11-26 14:09
Dialog::Dialog(QWidget *parent)
: QDialog(parent)
{
label1=new QLabel(this);
label1->setText(tr("<i>请输入圆的半径:</i>"));
lineEdit=new QLineEdit(this);
label2=new QLabel(this);
QPalette palette;
palette.setColor(QPalette::WindowText,Qt::red);
label2->setPalette(palette);
button=new QPushButton(this);
palette.setColor(QPalette::ButtonText,Qt::red);
button->setPalette(palette);
button->setText(tr("<font color=red>显示对应圆的面积</font>"));
QGridLayout *mainLayout=new QGridLayout(this);
mainLayout->addWidget(label1,0,0);
mainLayout->addWidget(lineEdit,0,1);
mainLayout->addWidget(label2,1,0);
mainLayout->addWidget(button,1,1);
// setLayout(mainLayout);
connect(button,SIGNAL(clicked()),this,SLOT(showArea()));
connect(lineEdit,SIGNAL(textChanged(QString)),this,SLOT(showArea()));
}