Skip to content
QtWS25 Last Chance
  • Qt Designer, QTextEdit, remove indentation

    Solved General and Desktop qtextedit indentation
    8
    0 Votes
    8 Posts
    3k Views
    D
    Hello, I reply this old topic but I could not find a solution for a problem. I want to set the padding of the text editor to zero. textEdit->document()->setDocumentMargin(0); as @mpergand said this works. However when I try to design application for different platform a problem occurred. On the mac the text is fit all the width of the texteditor, but in android there is always a small space at the end. Both text editors' width set to 150, on mac 45 of letter i can fit, on the phone 44i can fit and the small space. MAC [image: eda211d0-d08f-4d81-b24d-a28fa8c25b77.png] Android phone A34 [image: de938eab-51c8-47ea-bc4d-364b19e211c3.png] I tried all the below , none of them works part of the code: QTextDocument *doc = textEdit->document(); doc->setDocumentMargin(0); doc->setIndentWidth(0); textEdit->setContentsMargins(0,0,0,0); // textEdit->set QTextCursor cursor(doc); // Select the entire text cursor.select(QTextCursor::Document); // Create a character format and set the font style QTextCharFormat format; // QFont font("Arial", 12, QFont::Bold); // Example: Arial, 12pt, bold format.setFont(timesFont); // Apply the format to the selected text cursor.mergeCharFormat(format); // Set block format to ensure no extra margins QTextBlockFormat blockFormat; blockFormat.setBottomMargin(0); blockFormat.setTopMargin(0); blockFormat.setLeftMargin(0); blockFormat.setRightMargin(0); cursor.setBlockFormat(blockFormat); textEdit->setTextCursor(cursor); Why there is a difference ?