0

I want to make an URL with some parts extracted from a text file.

I have the following code:

crack_order = new QFile("orders.txt"); //I have QFile *crack_order in headers
crack_order->open(QIODevice::ReadOnly);

while(!crack_order->atEnd()){
    QStringList orders;
    orders =  QString(crack_order->readAll()).split('\n',QString::SkipEmptyParts);

    foreach (QString order, orders){
       ui->debugtextbox->setText(order); //until here, it works fine!
       url = "http://www.example.com/customers/orders/"+order+"/another/thing.txt";

It does not work, the URL request isn't performed correctly. However, if I put the following variable:

QString order = "12233";

before url, it works!

Then, I guess the problem is that it's getting the "order" from a text file, and QUrl doesn't like it.

Any idea?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
winker
  • 1
  • 1
    In programming--as in other kinds of deals--the purity matters. Are you perhaps dealing with [The Great Newline Schism](http://blog.codinghorror.com/the-great-newline-schism/)? Have you made sure that there aren't any stray carriage return characters in `order` that weren't handled by the `\n` line-feed split? Try checking the length of the order you read from the file as opposed to entered directly as a literal. Also: when posting, please make a [Minimal Crack Verifiable Example](http://stackoverflow.com/help/mcve) so others can compile and see the failure themselves. – HostileFork says dont trust SE May 17 '16 at 07:03
  • Try using `qDebug() <<` and see what the variables are. – Nicholas Smith May 17 '16 at 08:19
  • Debugger. Use. Variables. Show. – n. m. could be an AI Aug 25 '23 at 15:45

0 Answers0