Qt "Copy/Paste/Cut" - qt

Well, i'm doing a Text Editor, basically where you write the text is a "QPlainTextEdit" i'm having issues, i'm trying to do in "Edit" Menu, an option to Copy/Paste/Cut.
With Copy i meant, you select the text in the Editor, open Edit Menu, Click Copy and sends that to Clipboard.
Paste, pastes what you copied?
Cut, cuts the selected text.

QTextEdit has slots copy, paste and cut. So, You need just connect Your signals with these slots and You will have C-c\C-v functionality. You can do that in QDesigner without coding.

Related

Using links inside QTextEdit

ALL,
If I have a QTextEdit with the bunch of text and will want to insert a hyperlink in this text somewhere, will I get a handling of this hyperlink for free or I will have to write some additional code to handle the hyperlink hovering/clicking?
TIA!
[EDIT]
What I mean to ask was - whether it is possible QTextEdit to recognize the hyperlink after typing www.google.com and pressing either Space Bar or Enter key, so that it becomes rendered appropriately.
I don't want my user to type < a href=.....
Thank you and sorry for the confusion.
[/EDIT]

How to edit jupyter notebook shortcuts

Jupyter notebooks have a convenient means to edit shortcuts - by pressing H for help there is a button for it:
And here is the dialog to make the updates:
The question here is: when pressing add shortcut we apparently have a free form text field to enter the shortcut:
But whatever combination I put in actually causes some _system_wide_ kind of behavior to kick-in e.g. Command-R causes Jupyter to do something wacky, and I tried a couple of others. Is there another way to enter these?
Have you tried clicking on that link: details of defining keyboard shortcuts?
That gives some general tips on creating new shortcuts.
Your example might not work because you would want to use "Cmd-R" instead of "Command-R". Though, in my operating system, "Cmd-r" already does something(reloads the page). So whatever combination or sequence you choose, I'd make sure it doesn't already do something before using it as a shortcut.
Once you type into the field, are you clicking the "+" button to the right? If you click on that, it should then show if it's been set, and you can verify it set it to what you wanted. If you don't click the "+" button, it will have no effect.
Good luck!

Qt Designer add '&' (ampersand) in text automatically

I am using Qt 5.11.1 on Manjaro Linux.
When I open Qt Designer, create a new dialog and add stuff on the widget, Qt Designer adds '&' (ampersand) in the text in some types of widgets automatically. (Ampersand "&" is shortcut in Qt, commonly referred to as "mnemonic". For example, if text of button is "b&utton", I can click the button with Alt + U. See this answer for more information.) For example, if I create a radio button and set the text to "button", the text will become "b&utton" automatically, and I cannot remove the '&'. What should I do?
Not sure, probably qt_set_sequence_auto_mnemonic function is what you are looking for.
Specifies whether mnemonics for menu items, labels, etc., should be honored or not. On Windows and X11, this feature is on by default; on macOS, it is off. When this feature is off (that is, when b is false), QKeySequence::mnemonic() always returns an empty string.
Note: This function is not declared in any of Qt's header files. To use it in your application, declare the function prototype before calling it.
The workaroud in How to disable automatic mnemonics in a Qt application on KDE? works. Thank you Andrii for providing the link!
The workaroud is to add
[Development]
AutoCheckAccelerators=false
to ~/.config/kdeglobals.
I also found that removing the package kdelibs4support is also a workaround, but some packages might depend on it.

QListView and QAbstractListModel: how to manually set an item under editing, with cursor flashing?

I have a QAbstractListModel and QListView (for example, a list of input ports of an electronic device).
I've just added a row into the model, gave it a temp name (something like "RENAME_ME_PLZ_ASAP"). I want user to rename it, and I want to set the editing focus to this cell to make it possible to start typing the new port name without aiming the mouse to the cell added and double-clicking on it.
The editing of the item should begin, and its temp text contents should be selected (to be deleted by user when the typing will start).
How can it be done?
As you said you should should be able to edit, without aiming the mouse to the cell added and double-clicking on it.
Probably you can use QAbstractItemView::CurrentChanged edit trigger.
QListView *pListView = new QListView(<<Your parent widget>>); //rough
pListView->setEditTriggers(QAbstractItemView::CurrentChanged);
You have many edit triggers in below link, but I guess the above one suits you best.
http://doc.qt.io/qt-5/qabstractitemview.html#EditTrigger-enum
And if you are on embedded LINUX you can also use.
pListView->setEditFocus(true);
Well, I've just called QAbstractItemModel::edit(...) method.
^__^

How to unselect selected text in jupyter or how to make click & drag always select?

When I select a code in a Jupyter notebook cell, the code stays selected as long as I don't click into a different part of the same cell that is not selected. So, for example, if I select more text than I wanted, I have to click outside of the selection first, before being able to re-select the portion you want. This is very annoying, particularly if I select all the text within a cell and then want to select a smaller portion of text. I need to scroll up or down to the edge of the selection and click exactly before or after the selected text to unselect it again. Is there a way to make the jupyter notebook behave in a way that every click and drag creates a new selection rather than moving already selected text?
If I understood correctly, you want a way to reduce the size of the selected text area. You can do this holding shift-clicking within the selected text box, this will move the end-marker to the point where you clicked.
Unfortunately this only works with the end-marker and not the start-marker as is standard. I have raised a ticket with codemirror (the project that jupyter-notebook uses for the text editor).

Resources