PDA

View Full Version : User Editing QTextEdit



admkrk
7th May 2017, 08:56
I am trying to implement something similar to when you click the ellipse, in Creator, for text on a QLabel. In other words, I want the user to be able select between two tabs, one for rich text, with buttons for; bold text, underlined, etc, and another tab for HTML. I started to make a widget in Designer, but was stopped short by not finding a way to name the tabs. Between http://doc.qt.io/qt-5/qtwidgets-richtext-textedit-example.html and http://doc.qt.io/qt-4.8/qt-dialogs-tabdialog-example.html, I should be able to figure out the workings, but am wondering if it is possible, without hand coding everything. My reluctance to hand coding is mainly in visualizing the layouts, and being able to adjust them, when they do not work.

In addition, I am not sure how to connect the two tabs, like Creator does, although that might come from inherited classes that are not described in QTextEdit.

I also assume that I need to save the file in HTML format, and propagate it from there, when reopening it.

Santosh Reddy
8th May 2017, 09:40
Assuming you are using QTabWidget in designer, you change the tab text using "currentTabText" property, select the tab in designer and change the property value in properties editor
12456

admkrk
8th May 2017, 20:30
I was about to say I do not have that option, but figured it out when I was looking, to verify. What I was doing was selecting the tab itself (QWidget) in the object explorer. That gave me the yellow properties, but none of the green ones. All I could do was change the object name, that way.

While I still might try this, just for an experiment, I decided that it is overkill for my project. I think a simple rich text editor will be more than enough, since the user will not likely be very familiar with HTML. That just leaves me with trying to figure out how to insert an image with a button, drag and drop looks pretty straight forward, and inserting a table, as those ate not covered in the text edit example. I will worry about those when I get the rest of it working though.

Thanks again for your help.