void forceTextLayout() { // Hack: Qt does not do the layouting of the QTextDocument until QTextEdit comes visible on the // screen. // Need to force the layouting of the invisible QTextEdit/QTextDocument here by changing the // line wrap mode. // (Qt's default is QTEXTEDIT_WIDGETWIDTH). // This is needed in order that method's like getLineHeight(), getCaretLineNumber(), // getCaretLocation(), // setTopIndex, etc. work correctly also for invisble text widgets. if (isVisible()) return; OS.QTextEdit_setLineWrapMode(scrollAreaHandle, OS.QTEXTEDIT_NOWRAP); if ((style & SWT.WRAP) != 0) { OS.QTextEdit_setLineWrapMode(scrollAreaHandle, OS.QTEXTEDIT_WIDGETWIDTH); } }