QCString -> QByteArray

Roger Larsson roger.larsson at norran.net
Tue Feb 13 00:49:44 CET 2007


On Monday 12 February 2007 14:49, David Faure wrote:
> Converting a QCString to a QByteArray:
What if you like to do something more, like adding a character?

    for ( uint i = 0; i < numIterations; ++i ) {
        mBodyOld.duplicate( aStr.data(), aStr.length()+1 );
	mBodyOld += 'a';
    }

    for ( uint i = 0; i < numIterations; ++i ) {
        mBodyNew = aStr;
        mBodyNew.detach();
	mBodyNew += 'a';
        mBodyNew.truncate( aStr.size() -1+1);
    }

    for ( uint i = 0; i < numIterations; ++i ) {
        mBodyNew.duplicate( aStr );
	nBodyNew += 'a'; // Will this work without detach?
        mBodyNew.truncate( aStr.size() -1+1 ); // Note: changed object for 
size operation, correctly?
    }


More information about the Kde-optimize mailing list