Questions tagged [qstring]

A QString is a class in Qt library which implements character strings.

QString holds a unicode string inside, and provides a set of useful functions to manipulate the data, including easy concatenation, trimming, search and replace, and conversion functions.

QString can also be converted to std::string and vice-versa with toStdString() and fromStdString() respectfully:

QString str = QString::fromStdString( std::string("Hello, World!") );

std::string str = QString("Hello world!").toStdString();

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

791 questions
0
votes
1 answer

QString and OpenCV cv.namedWindow()

A Qt 4.8.1 C++ console application using OpenCV 2.4.2 is reading and displaying USB webcam images via the highgui module. It creates a window for displaying an image (using Qt internally itself I think) using the function void namedWindow(const…
handle
  • 5,859
  • 3
  • 54
  • 82
0
votes
0 answers

PySide/PyQt How to change text color for strings before appending them to QTextBrowser

I'm writing a program where I need to give any given string a color/highlight BEFORE adding it to the QTextBrowser. The string is stored in a variable so it doesn't seem to be possible to use HTML. Is there a way to do this?
UrbKr
  • 621
  • 2
  • 11
  • 27
0
votes
1 answer

QT4 QString compile error when add QT3_SUPPORT

I study some Qt3 code, My enviroment is QT 4 commercial, VS2010 with qt-addin. when I add the preprocessor "QT3_SUPPORT", the QString always with some error info like this: 1> main.cpp 1>main.cpp(18): error C2248: 'QString::operator…
user1279988
  • 757
  • 1
  • 11
  • 27
0
votes
1 answer

Qt endl looks great from linux telnet, wrong from windows telnet

I am building a telnet server app in Qt, and when I connect from a linux telnet client output looks great. For example, sending "A" << endl << "B" << endl << "C" to my console looks like: A B C Now when I connect from a Windows telnet client I…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Choose only one option between double brackets QString

I want to clean up QString data to have the following: input [[normal]], here's [[double phrased|brackets]] output normal, here's double phrased Just picking the first element in each sub-brackets is fine. I am not sure what the most optimal way…
y2k
  • 65,388
  • 27
  • 61
  • 86
0
votes
2 answers

Search QString character by character

I'm trying to parse a QString character by character with a while loop, but I can't figure out how to parse an individual character to char type. Here's my code, I know it's not optimal: QString temp = (QString)t[0]; int i = 1; while (t[i] != "…
0
votes
1 answer

Finding whether a large number of different values are present in a Qstring

I'm writing a program to check the file names in a directory and ensure they are following certain standards, one of these standards is that at the end of the file name it should have a version e.g. "file1V01.txt,file1V02.txt...file1V99.txt". I…
Vistari
  • 697
  • 9
  • 21
0
votes
1 answer

QString to String and vica versa

I am doing one project in which i have to use QT software. I have one qt variable like QString name_device; I am reading one .mat file using matIO library who has 1x3 Char variable with the similar name. Can anyone please tell me that how i can…
Saad Saadi
  • 1,031
  • 10
  • 26
0
votes
2 answers

How to get just one value from querystrig

I'm write this function: public static String QueryString(string queryStringKey) { if (HttpContext.Current.Request.QueryString[queryStringKey] != null) { if (HttpContext.Current.Request.QueryString[queryStringKey].ToString() !=…
0
votes
1 answer

Why doesn't QString overload + operator?

I've stumbled upon strange behavior when using operator+ on QStrings until I found out that QString doesn't overload operator+ (in contrary to std::string). What reasons are there not to do it (especially since they overloaded quite a bunch of other…
A Friedrich
  • 593
  • 6
  • 11
0
votes
1 answer

Qt: Path to file in QString

I have problem with storing a path to file in Windows in a QString. I'm using Qt with C++. QString resourcePath = ":/images/frog.bmp"; if( ! QFile::exists(resourcePath) ) { qDebug("*** Error - Resource path not found : %s", …
speedyTeh
  • 247
  • 1
  • 8
  • 22
0
votes
1 answer

how to reimplement qvalidator.validate() in api v2?

The code works fine in api v1, if i uncomment the top sip calls, then it means i'll be using v2, then of course i'll see errors like TypeError: invalid result type from Validator.validate() i know i need to change the return value of .validate() ,…
Shuman
  • 3,914
  • 8
  • 42
  • 65
0
votes
1 answer

How to convert a QString to a point (x, y, z) easily?

I have a struct point struct Point { double x; double y; double z; } And want to convert it to a QString "(value of x, value of y, value of z)" and convert it back? Any easy way? What I figured out for the forward conversion is QString…
user1899020
  • 13,167
  • 21
  • 79
  • 154
0
votes
1 answer

qt qstring toStdString loss of minus sign

I am using a qstring and using the function toStdString(). When I do this I lose a minus sign: '332-_09I_W' this text becomes: '332_09I_W' What can I do to prevent this? EDIT: Actually, the problem is not when i use toStdString(), it is when I set…
user1216527
  • 145
  • 1
  • 1
  • 11
0
votes
1 answer

how to place a "double" formated to 6 decimal digits into a QString?

I want to place a double into a QString with a format that yields 6 decimal digits. ie. %1.6f This crashes with memory dump: char *x = (char*)malloc(20 * sizeof(char)); for(int i; i < m_iBuild; i++){ std::fill_n(x, 20, '\0'); …
jdl
  • 6,151
  • 19
  • 83
  • 132