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. Justifying with tab spaces in the text

Justifying with tab spaces in the text

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 332 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.
  • H Offline
    H Offline
    Horia
    wrote on last edited by
    #1

    Hey,

    I'm creating a text editor and I am implementing the text alignments. All works fine except when justifying text with some tabs in it, for instance :

    "this is a a tab space"

    My code is quite simple :

    void setJustifyText(bool jusitfy)
    {
        QTextBlockFormat format;
        format.setAlignment(justify ? Qt::AlignmentFlag::AlignJustify : Qt::AlignmentFlag::AlignAbsolute);
        cursor.mergeBlockFormat(format);
    }
    

    And the error I get from Microsoft Visual Studio is :

    Debug Error!
    Program Qt\5.12.5\mscvc2017\bin\Qt5Cored.dll
    Module: 5.12.5
    File: text\qtextlayout.cpp
    Line:1780

    ASSERT: "(pos == end && glyphPosition == current.num_glyphs) || logClusters[pos] == glyphPosition" in file text\qtextlayout.cpp, line 1780

    Thanks for any help! I tried finding something in relation to this problem already on forums, but I didn't really find any proper solution to my problem.

    jsulmJ 1 Reply Last reply
    0
    • H Horia

      Hey,

      I'm creating a text editor and I am implementing the text alignments. All works fine except when justifying text with some tabs in it, for instance :

      "this is a a tab space"

      My code is quite simple :

      void setJustifyText(bool jusitfy)
      {
          QTextBlockFormat format;
          format.setAlignment(justify ? Qt::AlignmentFlag::AlignJustify : Qt::AlignmentFlag::AlignAbsolute);
          cursor.mergeBlockFormat(format);
      }
      

      And the error I get from Microsoft Visual Studio is :

      Debug Error!
      Program Qt\5.12.5\mscvc2017\bin\Qt5Cored.dll
      Module: 5.12.5
      File: text\qtextlayout.cpp
      Line:1780

      ASSERT: "(pos == end && glyphPosition == current.num_glyphs) || logClusters[pos] == glyphPosition" in file text\qtextlayout.cpp, line 1780

      Thanks for any help! I tried finding something in relation to this problem already on forums, but I didn't really find any proper solution to my problem.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Horia "Modifies the block format of the current block (or all blocks that are contained in the selection) with the block format specified by modifier." - is there a block or selection when you're calling this?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Horia
        wrote on last edited by
        #3

        @jsulm Hey and thanks for the reply, yes there is a proper selection with the cursor for the selected block/blocks in the selection.

        To be noted that justifying works fine without any tabs in the text, selection is handled properly.

        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