Add actions from QTextEdit to Edit Menu
-
Hello lads, so I need a way to add the context menu actions from QTextEdit to the Edit menu. I could re-implement these but there would be no point as their behaviour is exactly what I would like. Here is the context menu I am talking about
Another question is how do I add text beside this tick that shows and hides the Toolbar menu.
Thank you
-
Hi,
Nothing forbids you to have several actions calling the same slot.
How do you create that tick enabled menu ?
-
@mcosta said:
Hi,
if you want to extent the context menu you can follow the guideline provided here.
About the second question I think (sorry I'm on Mac and the menus are integrated in the system one) you should set the Menu
objectName
@SGaist said:
Hi,
Nothing forbids you to have several actions calling the same slot.
How do you create that tick enabled menu ?
The first issue is solved just by adding more slots and connecting them to the QTextEdit ones except Delete as it seems there is no slot for that. How would I implement the Delete action?
I would like to correct my self, the menu with the tick hides and shows the Toolbar and not the Menu. I did not create this menu. Setting the objectName does not add text beside the tick.
Thank ye both for your help, appreciate it!
-
@ChajusSaib said:
I would like to correct my self, the menu with the tick hides and shows the Toolbar and not the Menu. I did not create this menu. Setting the objectName does not add text beside the tick.
-
@mcosta I feel so stupid now (facepalm). Thank you
Anyone got an idea for implementing the Delete action? Thanks
-
Delete --> clear() ??
You could use the
QTextCursor
API -
@mcosta No delete only deletes/clears the selection, it does not remove everything. I will take a look at the QTextCursor API. Thank you once again mate!
-
Hi,
I think
QTextCursor::removeSelectedText()
is what you're looking forvoid MyEditor::slotDelete() { m_textEdit->textCursor().removeSelectedText(); }
should do the job
-
@mcosta You legend, thank you!
1/10