void XYZTextEditor::textDirection() {
    QTextCursor cursor = m_ui->textEdit->textCursor();
    QTextBlockFormat blockFmt = cursor.blockFormat();

    QTextOption topt = m_ui->textEdit->document()->defaultTextOption();
    if (m_ui->btnTextDirection->isChecked()) {
        topt.setTextDirection(Qt::RightToLeft);
        blockFmt.setLayoutDirection(Qt::RightToLeft);
    } else {
        topt.setTextDirection(Qt::LeftToRight);
        blockFmt.setLayoutDirection(Qt::LeftToRight);
    }
    m_ui->textEdit->document()->setDefaultTextOption(topt);
    cursor.setBlockFormat(blockFmt);
}
Esempio n. 2
0
void Stack::setTextDirectionRTL()
{
	if (m_current_document) {
		m_current_document->setRichText(true);
		QTextCursor cursor = m_current_document->text()->textCursor();
		QTextBlockFormat format = cursor.blockFormat();
		format.setLayoutDirection(Qt::RightToLeft);
		format.setAlignment(Qt::AlignRight | Qt::AlignAbsolute);
		cursor.mergeBlockFormat(format);
		emit updateFormatAlignmentActions();
	}
}