
Originally Posted by
mchara
If you want text to be written right to left while typing, try settin system language to hebrew and text edit should deal with inverted insertion automatically[we have no additional methods for right-to-left languages and if application is run in hebrew text edits inserts chars before cursor when typing(except numbers which are typed normally, so text cursor have strange arrow that show text direction].
Persian, like hebrew is written from right to left. Thus, the text typed in should be right-aligned. More so, if I have set the applications layoutDirection to Right to left as in this example:
right-to-left2.jpg
As you can see the line edit behaves the way it should. The TextEdit however doesnt and the text is still left-aligned. This looks very out of place for persian text (and other rtl languages.)
It should however do that depending on the language typed in so that one paragraph can be persian, the next one english and so forth ... and all be aligned correctly irrespective of the layoutDirection.
In kde only kedit is smart enough to handle that correctly. kwrite and kate do not (which doesn't come as a surprise since they both are built upon katepart). I really hope kate will handle that correctly in the newer version.
For the sake of completeness, here's the code for the above example:
#include <QtGui>
{
Q_OBJECT
public:
cw->setLayout(lo);
setCentralWidget(cw);
}
};
int main(int argc, char** argv)
{
app.setLayoutDirection(Qt::RightToLeft);
MainWindow mw;
mw.show();
return app.exec();
}
#include "main.moc"
#include <QtGui>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget* parent = 0) : QMainWindow(parent) {
QWidget* cw = new QWidget;
QVBoxLayout* lo = new QVBoxLayout;
lo->addWidget(new QLineEdit);
lo->addWidget(new QTextEdit);
cw->setLayout(lo);
setCentralWidget(cw);
}
};
int main(int argc, char** argv)
{
QApplication app(argc, argv);
app.setLayoutDirection(Qt::RightToLeft);
MainWindow mw;
mw.show();
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks