读书人

QT使用QRegExp内存泄漏是咋回事?请高

发布时间: 2012-05-30 20:20:04 作者: rapoo

QT使用QRegExp内存泄漏是怎么回事?请高手帮忙!

C/C++ code
#include "gotocell.h"#include "ui_gotocell.h"GoToCell::GoToCell(QWidget *parent) :    QWidget(parent),    ui(new Ui::GoToCell){    ui->setupUi(this);    QRegExp regExp("[a-z]");    QRegExpValidator *regExpVali = new QRegExpValidator(regExp,this);    lineEdit -> setValidator(regExpVali);}GoToCell::~GoToCell(){    delete ui;}void GoToCell::on_lineEdit_textChanged(){    butOk -> setEnabled(lineEdit -> hasAcceptableInput());    int i=0;}



一运行出现:内存不能为read的警告,这是怎么回事啊?高手帮忙看下,什么地方出问题了。



[解决办法]
lineEdit 要先new 出来在使用;
C/C++ code
[color=#FF0000]lineEdit = new QLineEdit[/color];lineEdit -> setValidator(regExpVali);()
[解决办法]
探讨
lineEdit 要先new 出来在使用;


C/C++ code

lineEdit = new QLineEdit;
lineEdit -> setValidator(regExpVali);()

[解决办法]
lineEdit = new QLineEdit;

读书人网 >QT开发

热点推荐