• 3618阅读
  • 0回复

内存报错..... [复制链接]

上一主题 下一主题
离线zouying650
 

只看楼主 倒序阅读 楼主  发表于: 2010-10-04
— 本帖被 XChinux 执行加亮操作(2010-10-21) —
[pre]bool MainWindow::maybeSave()[pre]{[/pre][pre] Q_ASSERT(textEdit);[/pre][pre] [/pre][pre] if(!textEdit->document()->isModified())[/pre][pre] return true;[/pre][pre] if(filename.startsWith(QLatin1String(":/")))[/pre][pre] return true;[/pre]
[pre] QMessageBox::StandardButton res = QMessageBox::warning(this,tr("Application"),tr("this file has been changed"[/pre][pre] "do you want to save it"),QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel);[/pre][pre] if(QMessageBox::Save == res)[/pre][pre] return save();[/pre][pre] else[/pre][pre] return false;[/pre][pre] return true;[/pre]
[pre]}[/pre][pre]————————————————————————[/pre][pre]textEdit是QTextEdit的一个实例,,实例是类似win的TXT文档编辑器,,[/pre][pre][/pre][pre]textEdit->document()得到文档内容,但是每次运行这行就报错,提示内存不能访问的数据.....[/pre][pre][/pre][pre]查找相关的文档[/pre][pre]
Note: The editor does not take ownership of the document
[/pre] unless it is the document's parent object.
The parent object of the provided document remains the owner of the object.
If the current document is a child of the text editor, then it is deleted.

————
牛人指点下
[/pre][pre][/pre]
[/pre]
我是谁
快速回复
限100 字节
 
上一个 下一个