qstring

QtCreator插件开发(三)——QtCreator架构

一笑奈何 提交于 2019-12-11 10:35:20
QtCreator插件开发(三)——QtCreator架构 一、QtCreator架构简介 QtCreator的核心就是一个插件加载器,其所有功能都是通过插件实现的。 QtCreator架构如下: QtCreator的核心功能由Core Plugin (Core::ICore)实现。 插件管理器(ExtensionSystem::PluginManager)对插件协作提供了简单方式,允许插件为其他插件扩展提供钩子。 PluginManager负责插件的加载,管理,销毁等工作。Core插件是QtCreator最基础的插件,提供了向界面增加菜单等功能。 QtCreator的核心系统是由PluginManager和Core插件构成。PluginManager负责插件的管理工作,Core负责提供QtCreator的最小功能集合。PluginManager将Core当做普通插件进行加载。对于自定义插件,Core是一个基础功能库,使用Core可以扩展QtCreator的功能。 QtCreator的所有功能,全是由插件实现的,使用插件机制的优点是简化了顶层业务,即插件管理工作的逻辑,缺点是增加了加载插件的复杂度,由于Core插件需要被其他插件依赖,所以qtcreator在插件加载时就必须要考虑插件之间的依赖性。 二、插件模块 1、插件模块 最基本的插件是一个共享库,从开发者的角度,插件是一个模块

Display QMessageBox with multiple arguments

只谈情不闲聊 提交于 2019-12-11 09:07:53
问题 I'm using the Qt framework and I'm a little rusty with it. I have two QStrings first and last I want to display them in a QMessageBox but don't know how to include multiple arguments. This is what I have to code it with on argument: QMessageBox::information(0, "Full Name", QString("%1 %2").arg(first)); How do I get the other argument ( last ) included in that output? 回答1: All of the arg()s return a QString so the following should work: QMessageBox::information(0, "Full Name", QString("%1 %2")

Qt QString maxsplit argument

情到浓时终转凉″ 提交于 2019-12-11 08:26:14
问题 Python strings have a function split() that can take a maxsplit argument (from Python docs): If maxsplit is given, at most maxsplit splits are done (thus, the list will have at most maxsplit+1 elements). If maxsplit is not specified or -1, then there is no limit on the number of splits (all possible splits are made). Can QStrings do this? I looked at the docs and there's no split() overload that takes an integer equivalent to maxsplit as argument. 回答1: It doesn't seem like it, though it seems

Get QString length (in characters, not bytes)

ⅰ亾dé卋堺 提交于 2019-12-11 04:10:37
问题 I need to get the actual character count (not byte count), similar to what is output when getting string length in V8. This is necessary for use with Twitter, which goes by character count no matter the language used, even with UTF-8 (it does NOT go by byte length). Ex: in chrome/chromium js console, or in nodejs: > "Schöne Grüße".length < 12 In Qt 4.8.2, trying QString someStr = "Schöne Grüße"; cout << someStr.length() will output 15, which is not what I'm aiming for. 回答1: I believe you need

Using the operator<< with a QStringList pointer

风流意气都作罢 提交于 2019-12-11 03:37:51
问题 How I can change this code? QString s="123"; QStringList *myList=new QStringList; myList<<s; Error: no match for 'operator<<' (operand types are 'QStringList*' and 'QString') *myList<<s; does not work too: myList is Empty, after this. 回答1: There is little to no point in using a pointer for a QStringList because this is an implicitly shared class due to the copy-on-write. You can find further details for that below: http://qt-project.org/doc/qt-5.1/qtcore/implicit-sharing.html Which means, I

How to count recurring characters at the beginning of a QString?

爷,独闯天下 提交于 2019-12-10 18:34:05
问题 Im dealing with a list of lines, and I need to count the hashes that occur at the beginning. # item 1 ## item 1, 1 ## item 1, 2 # item 2 and so on. If each line is a QString, how can I return the number of hashes occurring at the beginning of the string? QString s("### foo # bar "); int numberOfHashes = s.count("#"); // Answer should be 3, not 4 回答1: Trivially: int number_of_hashes(const QString &s) { int i, l = s.size(); for(i = 0; i < l && s[i] == '#'; ++i); return i; } In other languages

How to replace QRegExp in a string?

强颜欢笑 提交于 2019-12-10 10:34:24
问题 I have a string. For example: QString myString = "Today is Tuesday"; The requirement is: when user types a string, if that string is contained in myString , then that part in the myString should be bold, and case insensitive ( Qt::CaseInsensitive ), but the format of myString should remain (upper case characters should be upper case and lower case characters should be lower case). For example: user types: tu -> Today is Tu esday user types: ES -> Today is Tu es day user types: aY -> Tod ay is

Qt之正则表达式使用示例

岁酱吖の 提交于 2019-12-10 05:58:42
Qt之正则表达式使用示例 概述: 限定数字 :0-9 .h: .cpp: 执行效果图: over: 概述: 利用正则表达式对表格框内数据输入进行限制,首相先介绍一个正则表达式的区间条件 1.限定 0 到 9 可以写成 【0-9】 2.限定 A 到 Z 可以写成 【A-Z】 3.限定某些数字【110】 接下来写个小案列测试一下 限定数字 :0-9 .h: # include <QRegExp> //QRegExp类使用正则表达式提供模式匹配 private slots : void on_tableWidget_itemChanged ( QTableWidgetItem * item ) ; .cpp: void Regular :: on_tableWidget_itemChanged ( QTableWidgetItem * item ) { QString str = item - > text ( ) ; QRegExp rx ( "[0-9]" ) ; //设只输入范围数字0-9 QRegExpValidator v ( rx ) ; //QRegExpValidator类用于根据正则表达式检查字符串 int pos = 0 ; ui - > textBrowser - > append ( QString ( "匹配字符串 : " ) + str ) ;

Using both std::string and QString interchangeably

我只是一个虾纸丫 提交于 2019-12-10 03:17:02
问题 I use Qt extensively in a software system I'm working on for graphical and GUI components. However, for most internal algorithms and processing of data Qt plays a smaller role. I'll often run into the need to convert from std::string to QString or visa versa. My inclination is to use std::string as much as possible and use QString only when I need to pass strings to Qt classes like those that work with the file system. As I was programming this morning, it hit me that it may be bad design to