qstring

Decoding printf statements in C (Printf Primer)

I'm working on bringing some old code from 1998 up to the 21st century. One of the first steps in the process is converting the printf statements to QString variables. No matter how many times I look back at printf though, I always end up forgetting one thing or the other. So, for fun, let's decode it together, for ole' times sake and...

Qt UI for existing C++ project

I have already written a C++ program and I would like to write a GUI for it. I realize Qt is a wonderful tool, however, Qt has it's own classes, which make me quite confused. eg: instead of String, Qt has a class named QString.. I am wondering if I can mix C++ code and Qt code in C++? ...

Python/PyQT QString won't insert into MySQL database

Hi all, I am trying to trying to retrieve some values from a user using a QLineEdit widget. When a QPushButton raises a clicked event, I want the text to be retrieved from all QLineEdit widgets and stored in a local MySQL databaase. However, when I try to use string substition in the insert statement, the values don't get substituted. H...

Question about a QList<QStringList> in Qt

I'm using Qt 4.5 and im working with a QList<QStringList> which is a list of string list. Now I want to replace one string inside one stringList but with it seems unusual to type. I have found the following way of doing it and was wondering if it is ok: QList <QStringList> pDataList; pDataList[listIndex].replace(QStringIndex, newStri...

Qt QString cloning Segmentation Fault

Hi, I'm building my first Qt app using Qt Creator, and everything was going fine until I started getting a strange SIGSEGV from a line apparently harmless. This is the error: Program received signal SIGSEGV, Segmentation fault. 0x0804e2fe in QBasicAtomicInt::ref (this=0x0) at /usr/lib/qt/include/QtCore/qatomic_i386.h:120 By back...

Why have QString in struct sometimes a bad-ptr?

Hi there! 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 using: typedef struct RecorderPrintParam { ES_DataType xxxxxxxxxx; bool ...

using std::string with Qt causes run-time error on destruction

Hi. I have a Qt app that uses another library where the function output is std::string instead of a QString. So in my program I have a method void doSomething() { ... std::string std_string = MyExternalLibraryThatReturnsSTLstring.getString(); QString myQString = QString::fromStdString(std_string); ... process(myQString); ... } When ...

How to check wether a path represented by a QString with german umlauts exists?

Hey, i get a QString which represents a directory from a QLineEdit. Now i want to check wether a certain file exists in this directory. But if i try this with os.path.exists and os.path.join and get in trouble when german umlauts occur in the directory path: #the direcory coming from the user input in the QLineEdit #i take this QString...

How to produce Capital hexadecimal digits with QString::arg() ? [QT]

Hi, I'm trying to create a QString which is a hexadecimal number with its letter digits in Capitals instead of small caps, how can it be done? QString( " %1" ).arg( 15, 1, 16 ) yields f and I'd like F ...

Opening a file from a Qt String

I am making a Qt application and I have a button to open a file, which is connected to a custom slot. This is the slot code so far: void MainWindow::file_dialog() { const QFileDialog *fd; const QString filename = fd->getOpenFileName(); } How could I have it then convert the file name to a const char *, open the file, read it a...

Should non-QObject derived classes "always" be put on the stack?

Coming from the Symbian world, I'm used to using the heap as much as possible to avoid running out of stack space, especially when handling descriptors. CBase derived classes were always dynamically allocated on the heap, since if they were not, their member variables would stay uninitialized. Does the same convention apply to QObject-de...

QString, remove labels and content?

Hi, message.Text() is a QString. I want to remove some text. The text can be: Normal: "This is a text" With a label: "<label1>something</label1>This is a text" First, I find if the text has the label: !message.Text().contains("<label1>", Qt::CaseInsensitive)) So, if it has, I want to remove the first part, to have a normal text...

Parse and remove part of a QString

I want to parse some kind (or pure) XML code from a QString. My QString is like: <a>cat</a>My cat is very nice. I want to obtain 2 strings: cat, and My Cat is very nice. I think a XML parser is not maybe necessary, but in the future I will have more tags in the same string so it's also a very interesting point. ...

How to convert from BYTE* to QString?

I have a DATA_BLOB structure but I need to convert it to QString. How can I do this? ...

Converting an image to text

Hey everyone, I want to be able to save an image as text in a xml file and I can't manage to find a efficient way to do it ! So far I tried : QByteArray ImageAsByteArray; QBuffer ImageBuffer(&ImageAsByteArray); ImageBuffer.open(QIODevice::WriteOnly); rImage.save(&ImageBuffer, "PNG"); return QString(ImageAsByteArray.toBase64()); D...

QChar to wchar_t

Hello, I need to convert a QChar to a wchar_t I've tried the following: #include <cstdlib> #include <QtGui/QApplication> #include <iostream> using namespace std; int main(int argc, char** argv) { QString mystring = "Hello World\n"; wchar_t myArray[mystring.size()]; for (int x=0; x<mystring.size(); x++) { my...

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

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. ...