Qt界面编程积累
2013-11-28 23:34
344 查看
1.QTextEdit类成员函数中包含了用于文本查找的成员函数,可用于“查找”对话框的设计:
bool QTextEdit::find(const QString & exp, QTextDocument::FindFlags options = 0)
Finds the next occurrence of the string, exp, using the given options. Returns true if exp was found and changes the cursor to select the match; otherwise returns false.
根据介绍可以知道该函数用于查询指定的exp字符串,如果找到了就将光标跳转到查找到的位置,如果没有找到就返回false。这个函数还有一个QTextDocument::FindFlags参数,可以看到该参数是一个枚举变量,用来指定查找的方式,分别是向后查找、区分大小写、全词匹配等。如果不指定该参数,默认的是向前查找、不区分大小写、包含该字符串的词也可以查找到。这几个变量还可以使用“|”符号来一起使用。
2.QTextEdit类可以通过如下方法获取文本是否被编辑过:textEdit->document()->isModified();可以用于文本保存前的判断。
3.在进行较长时间工作时可通过如下方法掩饰界面的暂时无响应状态
QApplication::setOverrideCursor(Qt::WaitCursor);
out << ui->textEdit->toPlainText();
// 鼠标指针恢复原来的状态
QApplication::restoreOverrideCursor();
对QApplication的setOverideCursor函数解释如下:
voidQGuiApplication::setOverrideCursor(const
QCursor & cursor) [static]
Sets the application override cursor to cursor.
Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.
This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.
Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the curently active application override cursor.
Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.
可以看出QCoursor是Qt为显示光标定义的一个类,可以使用这个类进行自定义光标显示。
4.在Qt中,通过调用QApplication::clipboard()静态函数可以使用系统剪贴板,通过调用QClipboard::setText()就既可以在本应用程序中又可以在其他应用程序中使用放在剪贴板上的这些文本。再次使用QClipboard::text()函数就可获得放在剪贴板中的内容。
这里要注意的一个细节是对剪切可以看做是复制操作再加上一个删除操作。
bool QTextEdit::find(const QString & exp, QTextDocument::FindFlags options = 0)
Finds the next occurrence of the string, exp, using the given options. Returns true if exp was found and changes the cursor to select the match; otherwise returns false.
根据介绍可以知道该函数用于查询指定的exp字符串,如果找到了就将光标跳转到查找到的位置,如果没有找到就返回false。这个函数还有一个QTextDocument::FindFlags参数,可以看到该参数是一个枚举变量,用来指定查找的方式,分别是向后查找、区分大小写、全词匹配等。如果不指定该参数,默认的是向前查找、不区分大小写、包含该字符串的词也可以查找到。这几个变量还可以使用“|”符号来一起使用。
2.QTextEdit类可以通过如下方法获取文本是否被编辑过:textEdit->document()->isModified();可以用于文本保存前的判断。
3.在进行较长时间工作时可通过如下方法掩饰界面的暂时无响应状态
QApplication::setOverrideCursor(Qt::WaitCursor);
out << ui->textEdit->toPlainText();
// 鼠标指针恢复原来的状态
QApplication::restoreOverrideCursor();
对QApplication的setOverideCursor函数解释如下:
voidQGuiApplication::setOverrideCursor(const
QCursor & cursor) [static]
Sets the application override cursor to cursor.
Application override cursors are intended for showing the user that the application is in a special state, for example during an operation that might take some time.
This cursor will be displayed in all the application's widgets until restoreOverrideCursor() or another setOverrideCursor() is called.
Application cursors are stored on an internal stack. setOverrideCursor() pushes the cursor onto the stack, and restoreOverrideCursor() pops the active cursor off the stack. changeOverrideCursor() changes the curently active application override cursor.
Every setOverrideCursor() must eventually be followed by a corresponding restoreOverrideCursor(), otherwise the stack will never be emptied.
可以看出QCoursor是Qt为显示光标定义的一个类,可以使用这个类进行自定义光标显示。
4.在Qt中,通过调用QApplication::clipboard()静态函数可以使用系统剪贴板,通过调用QClipboard::setText()就既可以在本应用程序中又可以在其他应用程序中使用放在剪贴板上的这些文本。再次使用QClipboard::text()函数就可获得放在剪贴板中的内容。
这里要注意的一个细节是对剪切可以看做是复制操作再加上一个删除操作。
相关文章推荐
- 新浪微博开放平台研究-实现微博自动评论(下)
- qt 连接sqlserver 出现 “未发现数据源名称并且未指定默认驱动程序”的错误解决方法
- QTP自传之描述性编程
- Qt开发日记2
- QTP同时注释多行的技巧
- QT中的qmake详解
- 新浪微博开放平台研究-实现微博自动评论(上)
- 【转】软件测试工具LoadRunner中运行QTP脚本
- qtp参数化-通过excel导入到datatable中
- QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connect
- QT编译opencv
- 关于QT移植的触摸屏新的发现
- QT常用控件之QListWidget
- QT学习笔记
- MQTT初步研究文档
- ubuntu 下用qt必要组件
- qt 读写配置文件 ini
- 没有找到QtNetwork或者是无法打开QtNetwork 的解决方法
- 给Qt的控件添加新信号
- Qt的界面线程 和Mfc 一点不一样的地方