首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

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

2012-05-30 
QT使用QRegExp内存泄漏是怎么回事?请高手帮忙!C/C++ code#include gotocell.h#include ui_gotocell.hG

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;

热点排行