Results 1 to 3 of 3

Thread: How to use QWebView default context menu?

  1. #1
    Join Date
    Apr 2016
    Posts
    37
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Lightbulb How to use QWebView default context menu?

    hi all.

    i use Qt 5.4.2 , windows 7.

    i use QWebView load my html , my html include images.

    when i mouse right button pressed , QWebView default context menu is display.

    i see menu atcion has [open image] , [save image] , [copy image] , [copy image address].

    i use [copy image] and [copy image address] is valid.

    but [open image] and [save image] invalid , i want get this image src or other image information when [open image] [save image] tiggered.

    please help me.

  2. #2
    Join Date
    Apr 2016
    Posts
    37
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use QWebView default context menu?

    Why no one reply to me?

  3. #3
    Join Date
    Apr 2016
    Posts
    37
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use QWebView default context menu?

    I found the answer.

    when "Save Image" aticon clicked , i received downloadRequested signals.

    i get image src from QNetworkRequest.
    Qt Code:
    1. connect(this->page(),SIGNAL(downloadRequested(QNetworkRequest)),this,SLOT(slt_downloadRequested(QNetworkRequest)));
    To copy to clipboard, switch view to plain text mode 

    if "Open Image" aticon clicked :

    Qt Code:
    1. #define Flag_OpenImage 0
    2. #define Flag_SaveImage 1
    3.  
    4. connect(this->pageAction(QWebPage::OpenImageInNewWindow),SIGNAL(triggered(bool)),this,SLOT(slt_openImage_triggered()));
    5. connect(this->pageAction(QWebPage::OpenImageInNewWindow),SIGNAL(triggered(bool)),this->pageAction(QWebPage::DownloadImageToDisk),SIGNAL(triggered(bool)));
    6.  
    7. void slt_openImage_triggered(){
    8. m_iDefultMenuFlag = Flag_OpenImage;
    9. }
    10.  
    11. void slt_downloadRequested{
    12. if(m_iDefultMenuFlag == Flag_OpenImage){
    13. //do something ...
    14. }else if(m_iDefultMenuFlag == Flag_SaveImage){
    15. //do something ...
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    Thanks to the http://www.qtcentre.org .

Similar Threads

  1. Context Menu in Qt
    By GAURAV PANT in forum Qt Programming
    Replies: 1
    Last Post: 26th May 2014, 18:45
  2. Changing color to the default context menu
    By ciarlond in forum Newbie
    Replies: 1
    Last Post: 6th March 2012, 10:40
  3. Replies: 1
    Last Post: 4th November 2011, 11:25
  4. Context Menu
    By RY in forum Newbie
    Replies: 1
    Last Post: 10th September 2008, 07:59
  5. Disable context menu in QWebView
    By ivi2501 in forum Qt Programming
    Replies: 3
    Last Post: 26th August 2008, 09:59

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.