16,818
社区成员




#ifndef MY_OPTION_H
#define MY_OPTION_H
#include <QWidget>
class QLineEdit;
class QLabel;
class QPushButton;
class My_option : public QWidget
{
Q_OBJECT
public:
explicit My_option(QWidget *parent = 0);
protected:
QLabel *label1;
QLabel *label2;
QLineEdit *le_min;
QLineEdit *le_max;
QPushButton *certain_button;
int imin;
int imax;
signals:
public slots:
};
#endif // MY_OPTION_H
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QRegExpValidator>
#include <QRegExp>
#include "my_option.h"
My_option::My_option(QWidget *parent) :
QWidget(parent)
{
imin = 1; //初始化这2个竟然程序会出现错误: 程序已经停止
imax = 100;
this->setFixedSize(400, 200);
label1 = new QLabel(tr("range : "), this);
label2 = new QLabel(tr(" -- "), this);
label1->setFixedSize(60, 32);
label2->setFixedSize(60, 32);
le_min = new QLineEdit(this);
le_max = new QLineEdit(this);
le_min->setFixedSize(60, 32);
le_max->setFixedSize(60, 32);
label1->move(40, 40);
le_min->move(100, 40);
label2->move(160, 40);
le_max->move(220, 40);
QRegExp enter_num("[0-9]{1,4}");
QRegExpValidator *le_validator = new QRegExpValidator(enter_num, this);
le_min->setValidator(le_validator);
le_max->setValidator(le_validator);
certain_button = new QPushButton(tr("yes"), this);
certain_button->setFixedSize(60, 32);
certain_button->move(280 ,120);
}