Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. QtWebEngine vs QtWebKit context menu
Forum Updated to NodeBB v4.3 + New Features

QtWebEngine vs QtWebKit context menu

Scheduled Pinned Locked Moved Unsolved QtWebEngine
1 Posts 1 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JonBJ Offline
    JonBJ Offline
    JonB
    wrote on last edited by
    #1

    Please bear with me if I am a touch uncertain about classes/terminology/behaviour here.

    I inherited an application (Qt 4) using QtWebKit and QWebView. It allowed "preview" of HTML document, which the user could edit in-place via QWebPage::setContentEditable.

    The first thing I did was to port this to Qt 5.7. I therefore changed over to using QtWebEngine and QWebEngineView, allowing the user to edit in-place via QWebEnginePage.runJavaScript("document.documentElement.contentEditable = true");.

    All this went fine, and seemed to give identical behaviour. However, it appears there is one facility missing which is required. I cannot go back to look at the old code behaviour, but I have been shown an old screenshot with a right-click content menu where the user could select some text and then choose a font for the selection via a Fonts sub-item with choices Bold, Italic, Underline. Presumably this then changed the HTML source over the selected text.

    The menu seemed to have items like: Cut, Copy, Paste, Select All, Fonts>, Direction>. The menu now, however, has only items: Copy, Unselect. Doubtless in part because it no longer "internally" supports setContentEditable.

    1. Am I correct in my description of this difference between QWebView vs QWebEngineView?

    2. I see no evidence in our code of any handling of the old or new context menus. Are these indeed inbuilt from the Qt side?

    3. I think I see we have QWebEngineView::contextMenuEvent so I can extend the context menu. I guess I need to roll my own to add something like font selection?

    4. Assuming I can get through #3, I am worried about how I would know where to put what into which. Presumably I want to do something like wrap the selected text inside, say, <b> & </b>. But the user is in "HTML editable-preview mode". Any "selection point coordinates" I might get back are going to point into "what is on the screen", not the underlying text of the HTML which is behind it? Will I have access to the corresponding HTML at the right "position", and will I be able to insert an HTML element entity like <b> or will something likely treat the insertion as literal text, e.g. actually inserting &lt;b&gt; which of course I don't want?

    I should really appreciate some guidance in this area, at least to indicate whether this is going to be possible. Thanks in advance.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved