奇怪,, 在构造函数里面初始化竟然出现错误

renzha0013 renzha0013 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
求指点。
上代码:
option类
#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


option.cpp
#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);
}


在构造函数里面初始化 imin = 1; imax = 100; //初始化这2个竟然程序会出现错误: 程序已经停止
...全文

相关推荐

评论 11
收藏 已收藏
分享
返回顶部
renzha0013
Qt 21,503 成员 26,693 内容