qstring

QGIS PyQt4 missing QString class

不羁的心 提交于 2019-12-01 21:26:51
i was trying to use a QString in the QGIS Python Console. from PyQt4.QtCore import QString but it says: ImportError: cannot import name QString In my Python IDLE it works fine, but i know that QGIS brings its own PyQt4. What could be the problem here? And could i solve it? import PyQt4.QtCore PyQt4.QtCore.QString() and from PyQt4 import QtCore QtCore.QString() dosen't works anyway. I was thinking about to copy the QtCore4.dll from my own PyQt4 installation to QGIS, but QGIS uses QtCore.prl and QtCore4.lib instead of QtCore.pyd and QtCore4.dll, like it is used by my PyQt4 installation When i

How to remove accents / diacritic marks from a string in Qt?

半腔热情 提交于 2019-12-01 18:21:09
How to remove diacritic marks from a string in Qt. For example, this: QString test = QString::fromUtf8("éçàÖœ"); qDebug() << StringUtil::removeAccents(test); should output: ecaOoe There is not straighforward, built-in solution in Qt. A simple solution, which should work in most cases, is to loop through the string and replace each character by their equivalent: QString StringUtil::diacriticLetters_; QStringList StringUtil::noDiacriticLetters_; QString StringUtil::removeAccents(QString s) { if (diacriticLetters_.isEmpty()) { diacriticLetters_ = QString::fromUtf8("ŠŒŽšœžŸ

How to remove accents / diacritic marks from a string in Qt?

可紊 提交于 2019-12-01 18:00:35
问题 How to remove diacritic marks from a string in Qt. For example, this: QString test = QString::fromUtf8("éçàÖœ"); qDebug() << StringUtil::removeAccents(test); should output: ecaOoe 回答1: There is not straighforward, built-in solution in Qt. A simple solution, which should work in most cases, is to loop through the string and replace each character by their equivalent: QString StringUtil::diacriticLetters_; QStringList StringUtil::noDiacriticLetters_; QString StringUtil::removeAccents(QString s)

QString replace only first occurrence

耗尽温柔 提交于 2019-12-01 17:28:24
Is there simple way of replacing only first occurrence of some substring by other substring in QString? It can be at any position. You could try this: QString str("this is a string"); // The initial string. QString subStr("is"); // String to replace. QString newStr("at"); // Replacement string. str.replace(str.indexOf(subStr), subStr.size(), newStr); Resulting string will be: that is a string There is no convenience method for the operation you wish to have. However, you can use the following two methods to build your custom operation: int QString::indexOf(const QString & str, int from = 0, Qt

QString replace only first occurrence

前提是你 提交于 2019-12-01 17:25:53
问题 Is there simple way of replacing only first occurrence of some substring by other substring in QString? It can be at any position. 回答1: You could try this: QString str("this is a string"); // The initial string. QString subStr("is"); // String to replace. QString newStr("at"); // Replacement string. str.replace(str.indexOf(subStr), subStr.size(), newStr); Resulting string will be: that is a string 回答2: There is no convenience method for the operation you wish to have. However, you can use the

How to pass a QString to a Qt slot from a QMenu via QSignalMapper or otherwise

自古美人都是妖i 提交于 2019-12-01 17:07:46
I have a QMenu with many submenus. These are dynamically created i.e. the names menus come from a db and created in a loop. Now i wanted to fire the same slot triggered() or similar when a menu is clicked, but i needed the QString menu name to be passed to slot so i could perform menu specific actions. I have tried this i.e. passing a QAction * to the triggered event and used setData but i am getting the run time error. object::connect: No such signal QAction::triggered(QAction *) for(int j=0; j<channelTypes[i].getNumChannels() ; j++){ QAction *subMenuAct = subMenu->addAction(tr(c_name)); // c

QGroundControl Source Code Learning Series - 2

回眸只為那壹抹淺笑 提交于 2019-12-01 12:39:57
QGroundControl Source Code Learning Series - 2 AppMessages AppMessages 类主要用来处理程序运行过程中的消息及日志记录。 在使用 Qt 进行开发时,难以避免会使用 QDebug (QInfo | QWarning | QCritical) 等以及相应的宏(qDebug 等)来输出变量的值或特定消息。一般使用 QtCreator 开发 Qt 程序时,qDebug 会将调试信息输出到 QtCreator 的控制台中,我们在开发时用起来非常方便。但是一般将程序发布后,往往看不到输出的信息了,因此我们需要将输出信息重定向到将界面或者文件中以便查看。毫无疑问,AppMessages 就是实现这样的功能的。 AppMessages 对外的接口只有两个,并且这两个方法都是静态的方法: class AppMessages { public: static void installHandler(); static AppLogModel* getModel(); }; 在我看来,AppMessage 这个类更多的是充当一个 namespace 的功能。 installHandler 方法中会调用 Qt 提供的 qInstallMessageHandler 注册自定义的消息处理器。而 getModel 方法则提供了外部访问

【win】【qt5】【本地网络相关信息,诸如ip,mac等】

南笙酒味 提交于 2019-12-01 10:03:16
正文:   最近在做远程登陆需要用到电脑得mac地址,故学习后写下此文以为笔记。   注:都记得加网络模块 QT += network 和头文件哈。 内容:   qt获取本地mac,ipv6,ipv6,电脑名字。   cmd获得本地ip信息,本机配置信息。 正文:   1.获取计算机名称和ip信息      QString localHostName = QHostInfo::localHostName(); qDebug() << "localHostName:" << localHostName; //计算机名 QHostInfo info = QHostInfo::fromName(localHostName); //通过主机名获得主机信息 qDebug() << "IP Address:" << info.addresses(); //输出主机信息中的IP地址信息   第二个获取2个字段,第一个是本地的ipv6,一个是默认的即ipv4.   2.下面用函数来获取ip,mac,计算机名称。    1 QString name = get_localmachine_name(); 2 qDebug() << "电脑名字:" << name; 3 4 //本机连接名 5 QString Widget::get_localmachine_name() 6 { 7 QString

QtConcurrent::run 运行类的成员函数

ε祈祈猫儿з 提交于 2019-12-01 09:39:01
https://stackoverflow.com/questions/2152355/is-it-possible-to-use-qtconcurrentrun-with-a-function-member-of-a-class?answertab=active#tab-top // call 'QStringList QString::split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const' in a separate thread QString string = ...; QFuture<QStringList> future = QtConcurrent::run(string, &QString::split, QString(", "), QString::KeepEmptyParts, Qt::CaseSensitive); ... QStringList result = future.result(); 来源: https://www.cnblogs.com/liujx2019/p/11675512.html

Qt编写自定义控件70-扁平化flatui

耗尽温柔 提交于 2019-12-01 09:35:00
一、前言 对于现在做前端开发人员来说,FlatUI肯定不陌生,最近几年扁平化的设计越来越流行,大概由于现在PC端和移动端的设备的分辨率越来越高,扁平化反而看起来更让人愉悦,而通过渐变色产生的质感色彩反而没有扁平化来得亲切。 Flat UI是基于Bootstrap之上进行二次开发的扁平化前端框架,他提供了动感、时尚的风格色调搭配,简洁、炫丽的功能组件,同时还提供了更为平滑的js交互动画,可以称得上前端扁平化设计框架的优秀代表之一。 既然是扁平化设计框架的优秀代表,当然需要在自己项目中应用应用,本人最早使用VB开发,而后转为C#开发,最后转为Qt开发,都是因为公司项目需要,根据需要不断学习新的编程框架,语言都是相通的,举一反三,以前用C#写的vista时钟控件和vista日历控件,稍微改改就转移成了Qt写的对应控件,非常方便,只要掌握了思想,熟练了一门语言和框架之后,其他的学起来特别快。 Qt中的qss机制,和css极为相似,感觉就是脱胎于css,用qss来实现Qt界面样式不是一般的方便,而是相当的爽,在看到FlatUI这样的精美的扁平化设计样式后,难以抑制手痒痒,就想用qss实现类似的风格。 开源地址: https://gitee.com/feiyangqingyun/QWidgetDemo https://github.com/feiyangqingyun/QWidgetDemo