qtextedit

How to make right-to-left language (eg.Arabic) characters behave like left-to-right languages do in qt?

拈花ヽ惹草 提交于 2019-12-23 02:29:57
问题 Qt provides a powerful adaptive way to deal with left-to-right languages and right-to-left languages texts.But I encounter my problems dealing with my goals. Picture No.1 What I want to get Picture No.2 What I got when paste to my QTextEdit based widget what picture no.1 shows Picture No.3 What I got when I set text-direction to left-to-right as shown below: QTextDocument *doc = ui->textEdit->document(); QTextOption textOption = doc->defaultTextOption(); textOption.setTextDirection(Qt:

How to give QTextFrame or QTextBlock a background-image in QTextEdit?

梦想与她 提交于 2019-12-21 16:59:11
问题 I am developing an IM tool,as a part of it I have to develop a BubbleChatWidget on which all message items have a bubble-like background-image.I thought I could achieve my goal with QTextEidt ,but I don't know how to give 'QTextFrame' or QTextBlock a background-image. So my question is that how to give QTextFrame or QTextBlock a background-image in QTextEdit ?If QTextEdit can't satisfy my demands, how to achieve my goal with other Qt techniques ? The BubbleChatWidget may contains clickable

Create text area (textEdit) with line number in PyQt

喜夏-厌秋 提交于 2019-12-21 05:41:30
问题 I want to create textEdit with line number on the left side in PyQt like Notepad++. I tried this adding another textEdit but scrolling is stuck. I searched and found this question, but there is no good solution for it. 回答1: Is this what you are looking for CodeEditor example in pyqt based on the c++ http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html Putting it together for python3 (Im using PyQt4 not 5 but I guess it is similar) (and using QPlainTextEdit not QTextEdit see

PyQt or PySide: QTextEdit deselect all

允我心安 提交于 2019-12-19 09:26:37
问题 I'm using PySide(PyQt is fine as well) and I want to deselect everything inside a QTextEdit. Selecting everything is very easy and it's done by self.textedit.selectAll(), but I can't find a simple way to deselect everything. Is there a straightforward way to do it that I'm not aware of or is it more complicated than that? Thanks. 回答1: You want to first get the QTextCursor for the QTextEdit my_text_cursor = my_text_edit.textCursor() Then clear the selection of the QTextCursor my_text_cursor

How to highlight a string of text within a QTextEdit

狂风中的少年 提交于 2019-12-19 07:36:10
问题 I'm a student programmer currently developing an application for work using Qt4. I am building an equation editor and I'm having issues attempting to highlight a string within my QTextEdit field. I have a function that parses through the QTextEdit string and returns an a start and end integer of where an error is located. My original strategy was to use HTML tags at these two points to highlight the error. Unfortunately there appears to be an issue with html tagging and the equation syntax.

How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area?

孤街浪徒 提交于 2019-12-18 19:45:11
问题 How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area? It looks like it doesn't have any controlling function. 回答1: QTextEdit and QPlainTextEdit are both inherited from QAbstractScrollArea. The QAbstractScrollArea object provides access to the scrollbar through the verticalScrollBar() method. Thus, to jump to the top: ui.textEdit->verticalScrollBar()->setValue(0); And to jump to the bottom: ui.textEdit->verticalScrollBar()->setValue(ui.textEdit-

How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area?

寵の児 提交于 2019-12-18 19:45:08
问题 How to program scrollbar to jump to bottom/top in case of change in QPlainTextEdit or QTextEdit area? It looks like it doesn't have any controlling function. 回答1: QTextEdit and QPlainTextEdit are both inherited from QAbstractScrollArea. The QAbstractScrollArea object provides access to the scrollbar through the verticalScrollBar() method. Thus, to jump to the top: ui.textEdit->verticalScrollBar()->setValue(0); And to jump to the bottom: ui.textEdit->verticalScrollBar()->setValue(ui.textEdit-

How do I use QTextBlock?

荒凉一梦 提交于 2019-12-18 16:53:46
问题 I'm completely new to C++ and Qt. I want to populate a QTextEdit object with QTextBlocks , how do I do that? e.g. If I have the sentence "the fish are coming" how would I put each word into its own QTextBlock and add that block to QTextEdit , or have I misunderstood how QTextBlock actually works? 回答1: QTextEdit will let you add your contents via a QString : QTextEdit myEdit("the fish are coming"); It also allows you to use a QTextDocument , which holds blocks of text. The QTextDocument itself

A QWidget like QTextEdit that wraps its height automatically to its contents?

独自空忆成欢 提交于 2019-12-18 04:16:41
问题 I am creating a form with some QTextEdit widgets. The default height of the QTextEdit exceeds a single line of text and as the contents' height exceeds the QTextEdit's height, it creates a scroll-bar to scroll the content. I would like to override this behaviour to create a QTextEdit that would rather wrap its height to its contents. This means that the default height would be one line and that on wrapping or entering a new line, the QTextEdit would increase its height automatically. Whenever

Several ways of placing an image in a QTextEdit

随声附和 提交于 2019-12-17 23:29:41
问题 I think this is a very simple question, but when I copy an image I can't paste it in a QTextEdit? Paste is inactive! Also I would like to know how to drag-and-drop a picture. BTW I use the following code in order to insert a picture into a QTextEdit: QTextEdit *textEditor = new QTextEdit(0); QTextDocumentFragment fragment; fragment = QTextDocumentFragment::fromHtml("<img src='C:\\aaa.jpg'>"); textEditor->textCursor().insertFragment(fragment); textEditor->setVisible(true); Is it recommended?