PDA

View Full Version : Reimplementing a non-virtual slot



Berryblue031
14th March 2012, 15:47
I am attempting to override the copy() slot on QTextBrowser (so that it will only copy/paste plain text instead of text with html formatting).

According to this document (http://qt-project.org/faq/answer/is_it_possible_to_reimplement_non-virtual_slots) it should not be necessary for the slot to be virtual because it is not connected through the constructor. As I understand it from looking at the source the context menu is regenerated every time there is a context menu event i.e. you right click on the QTextBrowser.

However it is not working - the copy slot I declare in my subclass of QTextBrowser is not called when clicking the "copy" item in the context menu.

Does anybody have experience with this?

high_flyer
14th March 2012, 18:46
show your slot declaration, connection, and explain when it is connected.

ChrisW67
15th March 2012, 00:55
If your subclass instance is being addressed through a QTextBrowser* the inherited, non-virtual QTextEdit::copy() is what will be called.

Are you sure the copy() operation only places an HTML mime type in the clipboard? It's drag and drop operations carry plain text, HTML and rich text according to the docs.