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
2 answers

static QStringList is not keeping values

I want to keep a static location to write to, due to multiple instantiations. I want to be able to add to the list from each instantiation. But only the first one is kept. Not sure what to do? Works for pointer of type char. But when I tried…
jdl
  • 6,151
  • 19
  • 83
  • 132
0
votes
1 answer

How can I convert a char to QString?

Well this proves I'm a noob at coding! I've looked everywhere and still can't get this right. This should be pretty simple. I have been trying this: int i; for(i=0;i<16;i++) { QChar q = QChar(memblock[i]); QString s = QString(q); …
krb686
  • 1,726
  • 9
  • 26
  • 46
0
votes
1 answer

Qt5 QString and QPixmap

My image does not appear : QString champ("C:/champions/" + ui->comboBox->currentText() + "_1.jpg"); QPixmap image(champ); ui->label_1->setPixmap(QPixmap(image)); I tried to solve this for 2 hours. Help me please ! Sorry if my english is bad…
0
votes
1 answer

How to cut text placed beetween two words using regular expression?

I'm beginner in regular expressions and I want to cut some text placed beeween two other words. I'm using QT to do it. Some exapmle:
  • Feels like
    Filip J
    • 35
    • 3
  • 0
    votes
    0 answers

    Valgrind report an error with QString::toDouble

    I am writing a program in QT Creator and I just use these two lines in main.cpp function: QString a = "10.98"; double b = a.toDouble(); Everything seems fine, but when I check it with valgrind it reports a memory leak: valgrind --leak-check=full…
    TinF
    • 89
    • 7
    0
    votes
    1 answer

    QComboBox.currentText() -- PySide vs PyQt4

    I've got a python script using PySide and it works fine. But then I thought to check if it gonna work with PyQt4. And after changing the import strings to PyQt4, things went wrong. The error points to the subject, as follows: File "./my_file.py",…
    python_head
    • 105
    • 1
    • 4
    0
    votes
    1 answer

    C++ Qt QTableWidgetItem causes crash

    I have a QTableWidget called tw_topic. It's not empty. In another function I need the text of the items. Code : for(int i = ui->tw_topic->rowCount(); i >= 0; i--) { //should return the first item of the first column const QString itm =…
    0
    votes
    2 answers

    insert a content of integers array to the vector of QString

    I want to insert the content of array of integers : int arr[n] to the vector of QStrings. std::vector vQString.- I can do it by inserting the array`s elements one by one : vQString.push_back(QString::number(arr[i])); By I prefer to do that…
    YAKOVM
    • 9,805
    • 31
    • 116
    • 217
    0
    votes
    2 answers

    Qt QPixmap constructing with qstring filename

    I need to initialize a qpixmap object with its file directory It works if I do the following: image = new QPixmap("C:/Users/Administrator/Desktop/maze/HTetris-build-Desktop_Qt_5_0_1_MinGW_32bit-Debug/untitled/c12.bmp"); and it works with as…
    user1819047
    • 667
    • 9
    • 18
    0
    votes
    1 answer

    QString Remove numbers not associated with letters

    I am looking for a way to remove all numbers and letters in brackets, as well as numbers not associated with a letter (i.e. I want to keep 'v2' or 'vol.2'). For instance: "My Notes v02 003 (2009) (My sillyness)" would become: "My Notes v02". I…
    Eric
    • 1
    • 1
    0
    votes
    1 answer

    QTestLib results different from program output

    I have some simple code that reverses a QString. const QString reverse_qstring(const QString& str_in) { QString out; Q_FOREACH(const QChar c, str_in) { out.push_front(c); } return out; } When I input text from the command…
    taynaron
    • 704
    • 1
    • 10
    • 23
    0
    votes
    1 answer

    QString select lines range

    I have a huge QString (a big logfile), how do I select line 10 to line 20 for instance? Something like QString tenLines = bigHugeQstring.linesRange(10,20); is it possible?
    Johnny Pauling
    • 12,701
    • 18
    • 65
    • 108
    0
    votes
    1 answer

    Mysterious behaviour when trying to use the std::ostream streaming operator with QString

    I accidently tried to stream a QString with std::ostream. However, compilation (Windows SDK 7.1) succeeded, but put a warning: Warning:C4717: 'operator<<' : recursive on all control paths, function will cause runtime stack overflow Finally, I'm…
    braggPeaks
    • 1,158
    • 10
    • 23
    0
    votes
    1 answer

    Parsing texts between " " on a file to a QString

    I have a text file which looks like this: VariableA = 10 VariableB = 20 VariableC = "Hello World" The code works fine, but my trouble is getting the text strings between " ". QStringList Data; Data << "VariableA = " << "VariableB = " << "VariableC…
    Blastcore
    • 360
    • 7
    • 19
    0
    votes
    1 answer

    QString encoding with special character

    I m trying to convert QString with special character to const char but I did not succeed. my function is: void class::func(const QString& fileName) // fileName = "â.tmp" { qDebug()<< fileName; // display "â.tmp" const char* cfileName =…
    fa all
    • 11
    • 2