qtextedit

How to set cursor shape to '>' in a QTextEdit?

天涯浪子 提交于 2021-02-16 14:30:27
问题 I am trying to mimic a command-line client. I wish to set the cursor shape to '>', to show messages to user. I don't see that shape in the options provided by QCursor. Is there a way to set custom shapes to widget cursors? 回答1: You need to set the QTextEdit's viewport's cursor: http://doc.qt.nokia.com/stable/qtextedit.html "The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default. It can be changed through the viewport()'s cursor property." e.g. To hide the cursor completely

How to resize an image in a QTextEdit?

好久不见. 提交于 2021-02-06 09:28:09
问题 How to click on the image, hold from a corner of it, and resize the image in the QTextEdit? Or at least how to get an image under cursor/that is selected in order to change width and hight? 回答1: Here how I have implemented: void AdvancedTextEdit::resizeImage() { QTextBlock currentBlock = m_textEdit->textCursor().block(); QTextBlock::iterator it; for (it = currentBlock.begin(); !(it.atEnd()); ++it) { QTextFragment fragment = it.fragment(); if (fragment.isValid()) { if(fragment.charFormat()

Get QTextEdit changes when textChanged() signal is emited

℡╲_俬逩灬. 提交于 2021-02-04 18:28:47
问题 I have a QTextEdit and I connected the textChanged() slot to a signal. How can I find the changes when the signal is emitted. For example, I want to save the cursor position and the character written when I write something. 回答1: In the slot that gets called when the signal is emitted you can get the text with QString str = textEdit->toplainText(); . Also you can store the previous version of the string and compare to get the character that was added and its position. Regarding the cursor

save cursor position of qtextedit

无人久伴 提交于 2021-01-29 20:26:12
问题 setCurrentCharFormat() function does not take a current cursor position as a parameter. And so in order to set the char format for arbitrary text in the control I have to save the curent cursor position, set the char format and then restore it. However, I don't see any thing like cursorPosition() in the docs. Am I missing something? Or maybe there is a better way of doing what I want? 回答1: I think you're looking for the QTextEdit::textCursor() method which returns a copy of the editor's

How to split QTextEdit into pages?

≯℡__Kan透↙ 提交于 2021-01-29 09:24:53
问题 I'm using QTextEdit from C++ Qt5. I want to properly split and show rich text in numerated pages similarly to how it's done in Microsoft Word. I've tried document->setPageSize , however that does not work for me - text is still shown in one continuous page. 回答1: AFAIK QTextEdit doesn't support the word-processor-style concept of "pages". Rather, QTextEdit is designed around editing and viewing a continuous document, whose only delineation is at the level of "blocks" (i.e. paragraphs). Note

How can I know when the Enter key was pressed on QTextEdit

Deadly 提交于 2020-06-23 11:02:46
问题 I'm writing Chat gui for client on Python using PyQt5. I have a QTextEdit, which the client can write messages in it. I wan't to know when the 'Enter' key is being pressed while the focus is on the QTextEdit. I tried using installEventFilter function but it detects keys being pressed on all of the other widgets but the QTextEdit one. What can I do to fix that? def initUI(self): # ... self.text_box = QtWidgets.QTextEdit(self) self.installEventFilter(self) # ... def keyPressEvent(self,

How can I know when the Enter key was pressed on QTextEdit

荒凉一梦 提交于 2020-06-23 11:01:53
问题 I'm writing Chat gui for client on Python using PyQt5. I have a QTextEdit, which the client can write messages in it. I wan't to know when the 'Enter' key is being pressed while the focus is on the QTextEdit. I tried using installEventFilter function but it detects keys being pressed on all of the other widgets but the QTextEdit one. What can I do to fix that? def initUI(self): # ... self.text_box = QtWidgets.QTextEdit(self) self.installEventFilter(self) # ... def keyPressEvent(self,

Get data from QTextEdit line by line in QT [closed]

◇◆丶佛笑我妖孽 提交于 2020-04-07 05:54:47
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . hi, I would like to get information from TextEdit in Qt line by line and write it in vector. How it is possible to do thanks. Would like to get vectorarr = {"{9,1,6,6}","{0,4,3,11}","{3,22,8,33}","{11,3,8,3}"}; 回答1: You can get All QTextEdit text and split it by \n (new line). Get

Can I have single line sized QTextEdit with simple html?

笑着哭i 提交于 2020-03-02 12:26:23
问题 I need to display simple status row with text which will contain following styles: color bold italic QTextEdit can render simple HTML. But it also forcibly expands over multiple lines: Red background was added to emphasize the dimensions of the QTextEdit . Desired size is the size of one text line. How do I achieve that? 回答1: First of all, if you've simply used a QLabel , you'd not need to do anything special: it supports rich text format, and only takes as much space as necessary: #include