qstring

QString int

左心房为你撑大大i 提交于 2019-11-30 01:30:28
QString转int 直接调用toInt()函数 例: QString str("100"); int tmp = str.toInt(); 或者: bool ok; QString str("100"); int tmp = str.toInt(&ok); 注:ok表示转换是否成功,成功则ok为true,失败则ok为false。 2)int转QString QString::number(); 例: int tmp = 100; QString str = QString::number(tmp); 来源: https://www.cnblogs.com/herd/p/11544012.html

Convert an int to a QString with zero padding (leading zeroes)

我们两清 提交于 2019-11-30 01:06:48
I want to "stringify" a number and add zero-padding, like how printf("%05d") would add leading zeros if the number is less than 5 digits. chalup Use this: QString number = QString("%1").arg(yourNumber, 5, 10, QChar('0')); 5 here corresponds to 5 in printf("%05d") . 10 is the radix, you can put 16 to print the number in hex. QString QString::rightJustified ( int width, QChar fill = QLatin1Char( ' ' ), bool truncate = false ) const int myNumber = 99; QString result; result = QString::number(myNumber).rightJustified(5, '0'); result is now 00099 user1767754 The Short Example: int myNumber = 9; /

QT--动态人流量监测系统

馋奶兔 提交于 2019-11-29 17:43:37
QT--动态人流量监测系统 简介: 本项目 使用了百度AI的动态人流量监测api ,以人体 头肩 为主要识别目标,适用于低空俯拍,出入口场景,可用于统计当前图像的 锁定人数 和 经过的人数 项目功能 本项目分为 相机模块 和 图像识别模块 相机模块 使用了两个button复用、一个滑动条 按下 打开摄像头 button,开始准备拍照,button变成 关闭摄像头 button,再点击就关闭摄像头。 在打开摄像头之前, 开始 button是无法使用的。 当打开摄像头后按下 开始 button,button变成 停止 button,同时开始拍摄照片,由于是动态监测人流量,所以 抽祯频率为5fps ,也就是每秒需要拍摄上传5张照片,第一打开需要连接网络,所以可能有些慢。 滑动条在点击 开始 之前是无法使用的,当开始拍照后,可拖动滑动条切换窗口界面,进入监测界面 图像识别模块 图像识别模块可将相机模块拍摄的照片上传网络,进行人体识别,判断当前图片指定区域的人数、进入指定区域的人数,离开指定区域的人数 将图片上传到网络上后可获得返回的人数数值和渲染图片,显示在监测界面 图片中的人被锁定后会在人体头部出现矩形框 左边框为指定区域 画面左上角分别为 总的锁定人数 、 进入指定区域的总人数 、 离开指定区域的总人数 左下角为 此次打开运行 的人数 1. pro文件 QT += core gui

Why is QString printed with quotation marks?

微笑、不失礼 提交于 2019-11-29 17:02:44
问题 So when you use qDebug() to print a QString , quotation marks appears suddenly in the output. int main() { QString str = "hello world"; //Classic qDebug() << str; //Output: "hello world" //Expected Ouput: hello world } I know we can solve this with qPrintable(const QString) , but I was just wondering why does QString work like that?, and Is there a method inside QString to change the way it's printed? 回答1: Why? It's because of the implementation of qDebug(). From the source code: inline

How to specify a unicode character using QString?

允我心安 提交于 2019-11-29 16:24:00
问题 How can I specify a unicode character by code (such as "4FF0") using QString? I tried QString s("\u4FF0"); but it only outputs a question mark. Any idea how to do this? Edit: It works that way, but is there a more direct way? std::wstring str = L"\u4FF07"; QString s = QString::fromStdWString(str)); 回答1: If by direct you mean using a Unicode code point value, then QChar may be it: QString s = QChar(0x4FF0); 回答2: Apparently '\u' only works with UTF-8: QString s = QString::fromUtf8("\u4FF0"); //

How to convert a string representing decimal number in exponential form to float in Qt?

丶灬走出姿态 提交于 2019-11-29 15:36:45
I have some decimal numbers in a text file represented in exponential form Eg: 144.2e-3. I want to store the values in float. In qt it returns "0" when i directly use the "number.toFloat()" method. Please help. toFloat() should work. Check that your string contains only the number. If the string contains something else too, for example "144.2e-3 a" , then the toFloat() returns 0. Note that also other numbers in the string will cause the conversion to fail, for example QString("144.2e-3 100").toFloat() will return 0. Additional whitespace in the number string doesn't matter, but other

实现简单的计算器(计算功能模块实现)

前提是你 提交于 2019-11-29 13:45:51
1 #ifndef EXECUTE_H 2 #define EXECUTE_H 3 #include <QString> 4 5 class execute 6 { 7 public: 8 execute(); 9 void setnum1(int num); 10 void setnum2(int num); 11 void setflag(QString flag); 12 QString doexe(); 13 private: 14 int num1; 15 int num2; 16 QString flag; 17 }; 18 19 #endif // EXECUTE_H 1 #include "execute.h" 2 3 execute::execute() 4 { 5 num1=0; 6 num2=0; 7 } 8 9 void execute::setnum1(int num){ 10 this->num1 = num; 11 } 12 13 void execute::setnum2(int num){ 14 this->num2 = num; 15 } 16 17 void execute::setflag(QString flag){ 18 this->flag = flag; 19 } 20 21 QString execute::doexe(){ 22

QSettings::IniFormat values with “,” returned as QStringList

旧时模样 提交于 2019-11-29 12:30:24
I am using QSettings to parse an ini file: QSettings cfg(path, QSettings::IniFormat); When I obtain a value QVariant qv = cfg.value("title"); containing a comma the variant contains a QStringList instead of a QString title=foo => QString title=foo,bar => QStringList How can I always get strings, or at least obtain the original line ( title=foo,bar ) ? You have at least two ways to address this issue, all of them presented below: test.ini title="foo,bar" title_unquoted=foo,bar main.cpp #include <QSettings> #include <QDebug> int main() { QSettings settings("test.ini", QSettings::IniFormat); //

Qt编写控件属性设计器11-导入xml

 ̄綄美尐妖づ 提交于 2019-11-29 11:17:55
一、前言 上一篇文章负责把设计好的控件数据导出到了xml文件,本偏文章负责把导出的xml数据文件导入,然后在画布上自动生成对应的控件,Qt内置的xml数据解析功能,非常强大,都封装在QtXml组件中,Qt有个好处就是,封装了众多的各大操作系统平台的功能,尤其是GUI控件,不愧是超大型一站式GUI超市,虽然网络组件不是很强大,但是应付一些基础应用还是绰绰有余的。在导出xml数据的时候,属性列表和值都按照xml的属性存储的而不是子节点,所以在解析的时候需要遍历节点的属性名称和属性值,QDomNamedNodeMap attrs = element.attributes();然后循环挨个取出名称和值即可,QDomNode n = attrs.item(i);QString nodeName = n.nodeName();QString nodeValue = n.nodeValue(); 体验地址: https://pan.baidu.com/s/1A5Gd77kExm8Co5ckT51vvQ 提取码:877p 文件:可执行文件.zip 二、实现的功能 自动加载插件文件中的所有控件生成列表,默认自带的控件超过120个。 拖曳到画布自动生成对应的控件,所见即所得。 右侧中文属性栏,改变对应的属性立即应用到对应选中控件,直观简洁,非常适合小白使用。 独创属性栏文字翻译映射机制,效率极高

Qt编写控件属性设计器10-导出xml

好久不见. 提交于 2019-11-29 11:16:20
一、前言 能够导出控件布局和属性设置数据到xml文件或者其他文件,也是一个非常实用的功能,类似于QtDesigner中把页面设计好以后生成的.ui结尾的文件,其实就是xml文件,按照约定的规则存储好控件名称和属性名称及对应的属性值,然后打开的时候按照这个规则取出来就行了。每个控件还有固定的几个数据需要存储,比如XY轴和对应的宽度高度,然后在xml数据文件的最开始还可以存储整个画布的宽度高度以便其他用途。导出到xml格式,是为了方便解析,毕竟xml数据格式的解析,各种语言平台都有,而且都是非常成熟快速的。其实还可以考虑存储到数据库,这样就更加强大了,能够存储的东西更多,可以干的事情更多。 体验地址: https://pan.baidu.com/s/1A5Gd77kExm8Co5ckT51vvQ 提取码:877p 文件:可执行文件.zip 二、实现的功能 自动加载插件文件中的所有控件生成列表,默认自带的控件超过120个。 拖曳到画布自动生成对应的控件,所见即所得。 右侧中文属性栏,改变对应的属性立即应用到对应选中控件,直观简洁,非常适合小白使用。 独创属性栏文字翻译映射机制,效率极高,可以非常方便拓展其他语言的属性栏。 所有控件的属性自动提取并显示在右侧属性栏,包括枚举值下拉框等。 支持手动选择插件文件,外部导入插件文件。 可以将当前画布的所有控件配置信息导出到xml文件。