Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved Specific initialization of QTextEdit

    General and Desktop
    1
    1
    323
    Loading More Posts
    • 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.
    • Roy44
      Roy44 last edited by

      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 Reply Quote 0
      • First post
        Last post