other time...can't get date
Hi.
I do:
QString pepelu = lineaHora.left(6)+lineaHora.right(5);
QDateTime dias = QDateTime::fromString(pepelu,"yyMMddhhmm");
it gives me: 1003030900
I do:
hora->setText("Timess: " + dias.toString("yyMMddhhmm"));
But doesn't show me nothing in my label :(
Any help?
Many thanks and sorry for my english!
Re: other time...can't get date
Then something with your label is not right.
Code:
dias.setTime_t(1003030900);
l.setText(dias.toString("yyMMddhhmm"));
l.show();
works perfect. See if dias is valid where you want to use it. It seems to me your code confuses allocation on the heap and stack. Show us a little more code.
Re: other time...can't get date
Many thanks!
More code:
Code:
while (!file2.atEnd()) {
QString comHora
= lineaHora.
left(6);
QString comMinuto
= lineaHora.
right(5);
// asi me coge la hora
//BIEN QTime dias = QTime::fromString(comHora,"hms");
//QDateTime dias = QDateTime::fromString(comHora,"dd/MM/yy");
//QDate dia = QDate::fromString(comHora,"yyMMdd");
//QString pepelu = comHora+comMinuto;
QString pepelu
= lineaHora.
left(6)+lineaHora.
right(5);
//BIEN hora->setText("Timess: " + dia.toString("yyMMdd"));
// hora->setText("Timess: " + dias.toString("yyMMdd"));
hora->setText("Timess: " + dias.toString("yyMMddhhmm"));
QMessageBox::information(this,
"resultado",lineaHora.
left(6));
QMessageBox::information(this,
"resultado",lineaHora.
right(5));
//QMessageBox::information(this, "resultado",dia.toString());
//item->setText(line2);
//tabla->setItem(c,1,item);
//c++;
}
}
Thanks a lot,
Re: other time...can't get date
ok, first
Code:
QString pepelu
= lineaHora.
left(6)+lineaHora.
right(5);
6+5 = 11. yyMMddhhmm == 10! I think.
Then in the while loop you set the result every time on the same label. And I guess your last line which is precessed in an empty line. So the label will show nothing.
Re: other time...can't get date
Well, is something strange
The file have:
100303-0900
100303-1015
100303-1400
100303-1430
If I do:
QMessageBox::information(this, "resultado",lineaHora.right(6))
Gives me -1400
QMessageBox::information(this, "resultado",lineaHora.right(5))
Gives me 1400 when I think that if would give me: "-1400"
Many thanks and sorry for my english!
Re: other time...can't get date
Quote:
Originally Posted by
mmm286
If I do:
QMessageBox::information(this, "resultado",lineaHora.right(6))
Gives me -1400
QMessageBox::information(this, "resultado",lineaHora.right(5))
Gives me 1400 when I think that if would give me: "-1400"
Read the docs about readLine():
Quote:
The newline character ('\n') is included in the buffer.
Therefore you have to QByteArray::chop() first.
Re: other time...can't get date
Re: other time...can't get date