QT使用QRegExp内存泄漏是咋回事?请高手帮忙
QT使用QRegExp内存泄漏是怎么回事?请高手帮忙!
一运行出现:内存不能为read的警告,这是怎么回事啊?高手帮忙看下,什么地方出问题了。
------解决方案--------------------
lineEdit 要先new 出来在使用;
- 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 QLineEdit;