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. Tables in QTextEdit does not respect constraints
Forum Updated to NodeBB v4.3 + New Features

Tables in QTextEdit does not respect constraints

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 788 Views 1 Watching
  • 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.
  • DPalhariniD Offline
    DPalhariniD Offline
    DPalharini
    wrote on last edited by
    #1

    Hi everybory,

    I been trying to insert a table into a QTextEdit with fixed length, using insertTable with QTextTableFormat.

        QTextCursor cursor = textEdit->textCursor();
        QTextTableFormat fmt;
        fmt.setColumns(wNumColumn);
        // add constrains
        QVector<QTextLength> constraints;
        for (int i=0;i<wNumColumn;i++) constraints.append(QTextLength(QTextLength::FixedLength,wSizeFixed));
        fmt.setColumnWidthConstraints(constraints);
        fmt.setCellSpacing(0);
        cursor.insertTable(wNumColumn,wNumRow,fmt);
    
    

    The table cells does not respect the fixed constraints that I had set, if a single word size is bigger than the column size.
    0_1486565359781_upload-df92ea5b-fc88-4fc8-85a1-fefc2ded5a50

    If I use words smaller than the column size, the constraints were respected.
    0_1486565279705_upload-32b9d885-f3b9-49fc-89ed-265b916775ed

    BUT.. if I add "22222....." til the limit of the document and the QTextEdit breaks the line, the table respects size constraints.

    0_1486565442280_upload-ab113378-1e29-4801-9bd3-b4af25b3903c

    Once the table were resize by the line break, all cells respect the width constraints inserted.

    How could I fix this behavior? I tried to find some properties in the QTextTableFormat and (QTextTable object returned by the function insertTable) but so far nothing.

    Thanks in advance...

    1 Reply Last reply
    0
    • DPalhariniD Offline
      DPalhariniD Offline
      DPalharini
      wrote on last edited by
      #2

      I found the problem.

      Apparently the QTextTable does not limit the maximum table size when you fixed the column size.

      fmt.setWidth((wNumColumn-1)*wSizeFixed);
      
      1 Reply Last reply
      1

      • Login

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