Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Specific initialization of QTextEdit
Forum Updated to NodeBB v4.3 + New Features

Specific initialization of QTextEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 422 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Roy44R Offline
    Roy44R Offline
    Roy44
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved