Results 1 to 6 of 6

Thread: QWebView and Qt::Key_Menu problem

  1. #1
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QWebView and Qt::Key_Menu problem

    Hi

    I have QWebView object and I use customContextMenuRequested() signal connected to my slot createPopupForOutput(). Obviously I have 2 cases when my menu must appear: 1) after right mouse button (RMB) click and 2) after key Qt::Key_Menu press. RMB works as I expect, but Qt::Key_Menu works wrong (no menu appears). I debugged my app and discovered that in both cases my slot createPopupForOutput() is called properly (so this is no my event handing fault). I think that the only difference is that parameter to createPopupForOutput(const QPoint& aPoint) is (0, 0) when I press Qt::Key_Menu and aPoint has other values when I click RMB (for example (178, 46)). So my question is:

    How to raise custom popup menu on QWebView by pressing Qt::Key_Menu?

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView and Qt::Key_Menu problem

    The real question is where do you want to show it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Arrow Re: QWebView and Qt::Key_Menu problem

    I want show it near selection or url. Because this behaviour is natural and well known from webbrowsers.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView and Qt::Key_Menu problem

    So if the point you get is invalid, find the selection, get its geometry and show the menu there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Dec 2010
    Posts
    28
    Thanks
    6
    Thanked 10 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QWebView and Qt::Key_Menu problem

    How am I supposed to find geometry of selection or geometry of url?

    Now I use
    QWebHitTestResult lHit = mOutput->page()->mainFrame()->hitTestContent(aPoint);
    and when aPoint == (0,0)
    lHit.isContentSelected() == false
    !lHit.linkUrl().isEmpty() == false

    I have no idea how to handle special case when aPoint == (0,0) and some selection exist or some url link has focus.

    I looked in Browser demo from qt/demos/ directory. They made another approach - they subclass QWebView and redefine
    contextMenuEvent(QContextMenuEvent *event)
    It works but a bit weird: When some url has focus then after pressing menu key, menu appear in the upper left corner of the screen (not page corner, not window corner, but screen corner). Menu for selected text appear almost near selection but in my opinion that position is also invalid (distanse between selected text and menu is too big). And more! Menu for selected text is invalid - it has item "reload" instead "copy" (after RMB click it has "copy" - as supposed).

    I also searched web for "qt qwebview selection geometry" but find nothing apropriate.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QWebView and Qt::Key_Menu problem

    Quote Originally Posted by oficjalne100 View Post
    How am I supposed to find geometry of selection or geometry of url?
    No idea, most likely through QWebPage API.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Problem with QwebView
    By moh.gup@gmail.com in forum Qt Programming
    Replies: 3
    Last Post: 17th September 2010, 14:22
  2. Problem With QWebView
    By traxtopel in forum Qt Programming
    Replies: 2
    Last Post: 25th February 2010, 18:01
  3. QWebView problem
    By wirasto in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2009, 02:32
  4. Problem With QWebView
    By ivi2501 in forum Qt Programming
    Replies: 8
    Last Post: 2nd August 2009, 19:37
  5. Problem in QWebView
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2008, 19:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.