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

Can't use QString in a QLineEdit nor QComboBox as a parameter

I'm trying to make a function that replace the text inside a QLineEdit when the user want to revert is name to default using a QPushButton. This is where the code is getting "saved". `//Must get information in the DB lineditPlayerName = new…
Chax
  • 1,041
  • 2
  • 14
  • 36
0
votes
1 answer

QVariant is not able to distinguish between QDateTime and QString

I have a QDateTime object which I store in a QVariant and then I check the QVariant with type() but it behaves strangely when I check the type. void MainWindow::Test() { QDateTime myDate; // QDateTime; …
anbu selvan
  • 725
  • 3
  • 13
  • 41
0
votes
2 answers

Passing word count into dialog qt

I am building a notepad and want to count the words in a dialog. QString input = ui->textEdit->toPlainText(); int spaces = input.count(" "); ui->NumWordsLabel->setNum(spaces); This is my attempt so far. However, I want to execute this code in my…
sark9012
  • 5,485
  • 18
  • 61
  • 99
0
votes
2 answers

Turn QString to JSON

I have the following: QString notebookid = ui->notebookid->toPlainText(); QString tagid = ui->tagid->toPlainText(); QString userid = ui->userid->toPlainText(); QString subject = ui->subject->toPlainText(); QString comment =…
sark9012
  • 5,485
  • 18
  • 61
  • 99
0
votes
2 answers

qstring to short format for qlineedit

I tried this code but still have problem for QString to short value for example it work well for text = 20 but it return 0 for value = 20.5. but I need value=20. how can I solve it? inline __int16 GetStaticToInteger(QLineEdit* lineEdit) { …
citi
  • 31
  • 2
  • 7
0
votes
2 answers

QString to short using toShort

I want to convert QString to short.when I try this code ui->lineEdit->text().toShort(); It works well for text = 20 but it returns "0" for value = 20.5. but I need value = 20. how can I solve it?
citi
  • 31
  • 2
  • 7
0
votes
1 answer

Why have QString in struct sometimes a bad-ptr?

I've got an complicated error. The software send PrintParamters to a Printer a couple of times. At a certain moment all QStrings of the Parameter Struct are broken (bad ptr) Is there an general issue with QStrings in Structs? here is the struct I'm…
Christoferw
  • 741
  • 3
  • 7
  • 20
0
votes
3 answers

define function with #define in cpp?

i want check sth in if multiple time, i use #define for this ad i want to use it but it doesn't work #define CHECK_CONDITION(QString condition, start, curr) if(condition == "" ) return true; return (table.commonIn() == "team_id"?…
mari
  • 417
  • 1
  • 6
  • 21
0
votes
1 answer

Qt - Split and use string from lineEdit as regExp

I want to filter all my data by typing a string, sounds simple. This is what I got so far: stringToSearch.replace( QRegExp(" "), "|" ); QRegExp regExp(stringToSearch,Qt::CaseInsensitive, QRegExp::Wildcard);…
Jedi Schmedi
  • 746
  • 10
  • 36
0
votes
2 answers

Converting from cryptopp::integer to QString

How to convert from cryptopp::integer to QString? If it's important I work on Mac OS. I absolutely don't know what to do, only trying to use QCA, but it wasn't good enough!
0
votes
1 answer

cannot convert from int & missing default parameter for parameter 1

I am developing new project in Qt with existing MFC project . SO in MFC I have a function which uses SYSTEMTime and return CString. example CString getTimestampString( void ) { SYSTEMTIME systemTime; CString datestr; …
samprat
  • 2,150
  • 8
  • 39
  • 73
0
votes
3 answers

Error: no operand "<<" matches these operands when try to use Qstring with OStream object

Qt version 5.01 Platform windows 64 bit Issues:error: no operand "<<" matches these operands I have looked into the web but could not able to find solution for it. I have tried lots of things but it doesnt work. If I change QString to…
samprat
  • 2,150
  • 8
  • 39
  • 73
0
votes
2 answers

Split QString at - (dash) character, list item access

I tried to split a QString (a filename) and I want to get parts between two dash signs in the filname. The Filname is for example "0000000398_05WA-1384864213-218.bmp" . However, QStringList query; QString filename; QDirIterator it(qDirPictures,…
refuzee
  • 408
  • 4
  • 15
0
votes
1 answer

What's the cleanest way to emit a signal when QString is changed? (Qt)

I have a global QString object, and I would like to tie any changes to it to emit a Signal that I could connect to in other parts of my code. I see that the QString Class doesn't have signals, so how would I go about doing this? I'm using PyQt, but…
sebo
  • 1,584
  • 4
  • 16
  • 19
0
votes
2 answers

Can int values reset if too much is loaded at once?

In my C++ project, I have some int values (I am following two of them specifically). These values are input when the user loads a file. Their values (should) never change throughout the entire program. Later on in my program, I load about 30 MB of…
mrg95
  • 2,371
  • 11
  • 46
  • 89