Specific initialization of QTextEdit



  • I I would like to set a text with informations in a QTextEdit.
    Theses informations are specific and can't be stored in html.

    I already implemented the text creation: I set properties into QTextCharFormat
    (selected by text cursor).
    Now I want do the same thing to initialize my text edit.
    I would make somthing like that:

    QTextDocument* pDoc = pEditor->document();
        if(pDoc)
        {
            const int iChunkCount = qlChunk.size();
            int iChunkIndex = 0;
    
            QTextBlock blck = pDoc->begin();
            while(blck.isValid())// boucle par ligne
            {
                for(QTextBlock::iterator it = blck.begin(); !(it.atEnd()); ++it)// boucle par morceau de texte
                {
                    QTextFragment currentFragment = it.fragment();
                    if (currentFragment.isValid() && (iChunkIndex < iChunkCount))
                    {
                        QTextCharFormat fragmentCharFormat = currentFragment.charFormat();
                        if(qlChunk[iChunkIndex].m_vHeight.isValid())
                        {
                            fragmentCharFormat.setProperty(RTF_TEXT_SIZE_PROP_ID, qlChunk[iChunkIndex].m_vHeight.toDouble());
                        }
    
                        if(qlChunk[iChunkIndex].m_vAngle.isValid())
                        {
                            fragmentCharFormat.setProperty(RTF_TEXT_ANGLE_PROP_ID, qlChunk[iChunkIndex].m_vAngle.toInt());
                        }
    
                        if(qlChunk[iChunkIndex].m_color.isValid())
                        {
                            fragmentCharFormat.setProperty(RTF_TEXT_COLOR_PROP_ID, qlChunk[iChunkIndex].m_color);
                        }
                        iChunkIndex++;
                    }
                }
                blck = blck.next();
            }
        }
    

    I hope, it's clear.
    Sorry for my bad english.
    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.