Printing white spaces in QTextEdit



  • Hi, i want to see the White spaces. For example a Point for space, an arrow for tab and so on.

        QTextOption option;
        option.setFlags(QTextOption::ShowLineAndParagraphSeparators | QTextOption::ShowTabsAndSpaces);
        doc->setDefaultTextOption(option);
    

    This doesn't work, why?

    Please help me. Thanks

    Henrik



  • Hi Henrik,

    It should work ok, did you set the document into the QTextEdit using this method?

    QTextEdit::setDocument;

    This code worked for me:

        QTextEdit *te = new QTextEdit(this);
        QTextDocument* doc = new QTextDocument(this);
        te->setDocument(doc);
        te->insertPlainText("  test\n");
    
        QTextOption option;
        option.setFlags(QTextOption::ShowLineAndParagraphSeparators | QTextOption::ShowTabsAndSpaces);
        doc->setDefaultTextOption(option);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.