QString conversion to char format
-
Hello :
I need have this ?
@char buffer[80] = "";
sprintf( buffer, "%s%s_04i.%s", "C:\Test\MyImage", "Sector_", index, "png" );
@the result will be :
@"C:\Test\MyImage\Sector_00000.png
"C:\Test\MyImage\Sector_00001.png
"C:\Test\MyImage\Sector_00002.png
"C:\Test\MyImage\Sector_00003.png
@hmm ... but then the dialog "lineEdit", return a QString ...
@
QString strCache = ui->edt_CachePath.text() //. Return QString not char;
QString strSector = ui->edt_CacheSector.text() //. Return QString not char;QString strResult = "";
for(int index = 0; index< 1000; index+=1) {
QtextStram(&strResult) << strCache << "/" << strSector << index << ".png";
strResult = "";
}
@the result is:
@
"C:\Test\MyImage\Sector_8.png"
"C:\Test\MyImage\Sector_9.png"
"C:\Test\MyImage\Sector_10.png"
"C:\Test\MyImage\Sector_11.png"//. Remember sprintf () is : "C:\Test\MyImage\Sector_00008.png"
@how for fill Zeros in QString,,,
and how Convert QString to char ?? -
Hello:
Sorry I Find the Alternative Solution .... Thanks !!!@
#include <QCoreApplication>
#include <QDebug>int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QString strResult = ""; QString strCaches = "C:\\Test\\MyFolder"; QString strPrefix = "Sector_"; //. [1] for(int index=0; index<10; index+=1){ strResult = QString("Sector_%1").arg(index,5,10,QLatin1Char('0')); qDebug() << strResult; } qDebug() << " ---------- Case 2 -------------- "; //. [2] for(int index=0; index<10; index+=1){ strResult = QString("%1\\%2%3").arg(strCaches).arg(strPrefix).arg(index, 5, 10, QLatin1Char('0')); qDebug() << strResult; } return a.exec();
}
@