qtwebenginecore.rst 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // @snippet qwebenginepage-async-note
  2. .. note:: We guarantee that the ``resultCallback`` is always called, but it
  3. might be done during page destruction. When ``QWebEnginePage``
  4. is deleted, the callback is triggered with an invalid value and it
  5. is not safe to use the corresponding ``QWebEnginePage``,
  6. ``QWebEngineFrame``, or ``QWebEngineView`` instance inside it.
  7. // @snippet qwebenginepage-async-note
  8. // @snippet qwebenginepage-findtext
  9. Finds the specified string, ``subString``, in the page, using the given
  10. ``options``. The ``findTextFinished()`` signal is emitted when a string search
  11. is completed.
  12. To clear the search highlight, just pass an empty string.
  13. The ``resultCallback`` must take a ``QWebEngineFindTextResult`` parameter.
  14. // @snippet qwebenginepage-findtext
  15. // @snippet qwebenginepage-tohtml
  16. Asynchronous method to retrieve the page's content as HTML, enclosed in HTML
  17. and BODY tags. Upon successful completion, ``resultCallback`` is called with
  18. the page's content.
  19. // @snippet qwebenginepage-tohtml
  20. // @snippet qwebenginepage-toplaintext
  21. Asynchronous method to retrieve the page's content converted to plain text,
  22. completely stripped of all HTML formatting.
  23. Upon successful completion, ``resultCallback`` is called with the page's content.
  24. // @snippet qwebenginepage-toplaintext
  25. // @snippet qwebenginepage-runjavascript
  26. Runs the JavaScript code contained in ``scriptSource`` script on this frame,
  27. without checking whether the DOM of the page has been constructed.
  28. To avoid conflicts with other scripts executed on the page, the world in which
  29. the script is run is specified by ``worldId``. The world ID values are the same
  30. as provided by ``QWebEngineScript.ScriptWorldId``, and between 0 and 256. If
  31. you leave out the world ID, the script is run in the ``MainWorld`` (0).
  32. When the script has been executed, the callable ``resultCallback`` is called
  33. with the result of the last executed statement.
  34. Only plain data can be returned from JavaScript as the result value.
  35. .. note:: Do not execute lengthy routines in the callback function, because
  36. it might block the rendering of the web engine page.
  37. // @snippet qwebenginepage-runjavascript
  38. // @snippet qwebenginepage-printtopdf
  39. Renders the current content of the page into a PDF document and returns a byte
  40. array containing the PDF data as parameter to ``resultCallback``.
  41. The page size and orientation of the produced PDF document are taken from the
  42. values specified in ``layout``, while the range of pages printed is taken from
  43. ``ranges`` with the default being printing all pages.
  44. .. note:: The ``QWebEnginePage.WebAction.Stop`` web action can be used to
  45. interrupt this operation.
  46. // @snippet qwebenginepage-printtopdf
  47. // @snippet qwebenginepage-findframebyname
  48. Returns the frame with the given ``name``. If there are multiple frames with
  49. the same name, which one is returned is arbitrary. If no frame was found,
  50. returns ``None``.
  51. // @snippet qwebenginepage-findframebyname
  52. // @snippet qwebengineframe-printtopdf
  53. Renders the current content of the frame into a PDF document and returns a byte
  54. array containing the PDF data as parameter to ``resultCallback``. Printing uses
  55. a page size of A4, portrait layout, and includes the full range of pages.
  56. .. note:: The ``QWebEnginePage.WebAction.Stop`` web action can be used to
  57. interrupt this operation.
  58. // @snippet qwebengineframe-printtopdf