Problems with Open-Source Downloads read https://www.qt.io/blog/problem-with-open-source-downloads and https://forum.qt.io/post/638946
[Solved] Help needed in using qstringlist with qfile and qbytearray !!!
Hi everyone, am a newbie to Qt Development. Actually I wanted to develop an application with the below requirement.
Copying file contents which consists of some integer id's like 2201, 2255, 2386 etc. to a qstringlist and comparing each single element with a qbytearray function i.e qbytearray::contains. Can anyone of you help me with this please.
I have written some code below with no error but couldn't get output, can't understand where the problem is.
int main(int argc, char *argv)
QApplication a(argc, argv);
// tcpSocket tcpsocket;
demo::demo(QWidget *parent) :
ids.open(QIODevice::ReadWrite | QIODevice::Text);
file = QTextCodec::codecForMib(1015)->toUnicode(ids.readAll());
QStringList list = file.split(".",QString::SkipEmptyParts);
The program has unexpectedly finished.
19:12:03: Running steps for project socket...
19:12:03: Configuration unchanged, skipping qmake step.
19:12:03: Starting: "/usr/bin/make"
make: Nothing to be done for `first'.
19:12:03: The process "/usr/bin/make" exited normally.
19:12:03: Elapsed time: 00:00.
What is the content of file ? Can you paste it ? Any reason you are doing unicode etc ? Here either file or list is null. If your intent is just read and split according to ",", you can read the contents using readLine() and split the string using split function.
Thanks for the reply Dheerendra, my ids.txt file contents are mentioned below.
@2103, 2204, 2296, 7485, 9375@
As I have mentioned previously am a newbie to this c++ coding and all can you give any info regarding these unicode, binary and ascii etc., please.
So your error is very clear then. Look at your split. You are doing split through "."(dot). You should split your line through ","(comma)
Try the following two lines. Replace your split @line 22 with following two lines.
@ qDebug() << " Line =" << file <<endl;
QStringList list = file.split(",",QString::SkipEmptyParts);@
After this, let me know what happens.
Thanks Dheerender it worked amazing. Actually mine was a typo error from typing ',' I typed a '.' . So now the issue is solved thanks alot. :)
cool. Move this issue to SOLVED state by modifying the subject line of this issue.