qt5.Webview component - how to replicate qt5.WebKit.HitTest method

Post

Posted
Rating:
#1 (In Topic #1177)
Trainee
ask4nix is in the usergroup ‘Trainee’
 I do most of my coding in Debian 12 with the KDE Plasma desktop and use the Gambas qt5 toolkit. I have 2 apps where I use the qt5.Webkit component, specifically the Webview in that component, as an HTML editor. And I use the Webview.HitTest method to test whether I am clicking on an image, a link, or text in the Webview.  But the qt5.Webkit looks like it is being phased out - it seems not to be included in the default Debian Gambas3 install (although it's still available in the respositories), and I can no longer find it at all in the Arch or AUR repositories, so my apps won't run on Arch-based distros). Instead it has been replaced by the newer gb.qt5.Webview component, which unfortunately doesn't seem to provide a HitTest method. I would be grateful for any advice on how retrieve information on what kind of object (image, link or text) I have selected when I click on something inside the Webview element in the qt5.Webview component. In other words, if I click inside the Webview element of the gb.qt5.Webview, how can I replicate the behaviour of WebView.HitTest in the older qt5.Webkit component?
Thank you
Online now: No Back to the top

Post

Posted
Rating:
#2
Trainee
ask4nix is in the usergroup ‘Trainee’
Some further thoughts on this. I'm not even sure if there are other Gambas3 controls that offer the same functionality as gb.qt5.Webkit for editing html content, so my original question might not be relevant. I did re-check the Arch AUR and found build scripts for qt5.Webkit there, but on second thoughts it is highly likely that gb.qt5.Webkit is optimised for Gambas and the AUR build would not work anyway. So I guess I will just stick with Debian and maybe build an AppImage following the guidelines in  Gambas One - Gambas ONE if I want to support other distros.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

ask4nix said

if I click inside the Webview element of the gb.qt5.Webview, how can I replicate the behaviour of WebView.HitTest in the older qt5.Webkit component?
Thank you
Hi, a bit late maybe, but nevertheless. I get your pain, I used to have some nice fancy stuff going in qt4 webkit (quite a while ago). Recently I came in need of using webview and since qt5.webkit is slowly being out-phased on several distro's (hasn't been maintained for years and there seem to be security concerns) I decided to have a look at qt5.webview.

I can say, that is a whole other beast and compared to qt5.webkit it's like you have no options. But apparently you do, just takes time to figure out as  it is yet another on documented component where it is up to us to figure it out  ;)

I can help you with one thing, as I wanted to open a link on a webpage in another form, but didn't know how to detect and intercept it. So here is some sample code to figure out a link was clicked and to get the actual url of the link clicked. I will use a qt5.webview control named WebView1 in code below:

Code (gambas)

  1. 'Code to intercept a link if a link is clicked
  2. 'in a WebView control provided by qt5.webview component
  3. 'If no link is clicked WebView1.Link is Null
  4.  
  5. Public Sub WebView1_MouseDown()
  6.  
  7.   Debug "Link clicked is: " & WebView1.Link
  8.  
  9.  
I don't know about images and such (didn't need it so far), just the link thingy.

Enjoy…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
ask4nix is in the usergroup ‘Trainee’
 Thanks gbWilly and apologies for the late acknowledgement. I've been too busy with other things to give much thought to coding.
For years I used Zim Wiki as my go-to personal information manager. But it doesn't do all the things I would like it to do, so I began writing my own (not surprisingly called ask4nix) in Gambas back in about 2015. I started with something based on Moviga Notes by Jornmo which I found on the old forum hosted by Scholzy. Since then I've developed it to manage multiple notebooks, a rather nice and intuitive tagging system (IMHO), attachments and embedded images, and links within and between notebooks. The notes themselves are stored as html and plain text files, and I use an sqlite database simply for holding note metadata and indexing. If the sqlite database becomes corrupted (possible, but unlikely), it can be quickly rebuilt from the content of each note folder. I currently use both my own html editor and an enhanced version of the one by ShordiSoft on Gambas Farm. Both are based on the qt5-webkit. I messed around with the qt5-webview briefly, but given the lack of documentation on it and other more pressing tasks, I decided to take the path of least resistance and continue to code in Gambas 3.18 (Debian Bookworm) which still contains the qt-webkit. I then package my ask4nix app as an appimage, which runs quite well in the likes of Mint, Fedora, Endeavour OS, Manjaro and hopefully Debian Trixie when it's released. I know that sooner or later I will have to bite the bullet and code the html editor with either the qt5-Webview or qt5-TextEdit. But that will have to wait until I have a bit more free time and I can find more complete documentation for the qt5-webview or some example of how to use it at an html editor (I'm just a rank amateur when it comes to coding)
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

ask4nix said

I then package my ask4nix app as an appimage, which runs quite well in the likes of Mint, Fedora, Endeavour OS, Manjaro and hopefully Debian Trixie when it's released.
Up to bookworm the dependencies for qtwebkit are available on Debian. As of Trixie it is no longer possible to build the gb.qt.webkit packages as dependencies are no longer available. It will leak down to Ubuntu/LinuxMint future versions as well, as they are based of debian repositories, and it's also happening in other distro's, as you mentioned before.

So, it is NOT a matter of Gambas, but of distro. The latest OSB repositories, should have webkit packages for ALL distro's that have the available dependencies to build the gb.webkit package, like bookworm.
But I'm afraid webkit is gonna go in future distro's and that is a shame as webview component is rather meager compared to webkit.

It's called progress, losing possibilities and choices.  :shock:

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#6
Trainee
ask4nix is in the usergroup ‘Trainee’
 Yes, I currently dual boot Manjaro and EndeavourOS, and I might move to Debian Trixie when it is released. None of these provide support for the qt-webkit. So I code in a Debian Bookwork KDE virtual machine (Gambas 3.18), then move the project to a Mint 21 (Gambas 3.19) virtual machine to create the AppImage. Both have Gambas updates set on hold. I know this goes against the best advice on the forum, but for the moment I have no practical alternative.
The AppImage contains all the dependencies needed to run, but has some minor (annoying) inconsistencies in interface  font sizes  between different distros (even with the same desktop - in my case KDE Plasma ).  I can tweak it a bit by providing runtime options for interface fonts, but it's still not the best. However, I can live with that for the moment.
As for a replacement for the old qt-webkit, in addition to the current qt-webview, I think that the TextEdit and GridView/TableView controls are multi-line and html aware.  I'm not sure if they might also be 'not-so-easy-to-code' alternatives.
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
gbWilly leads the usergroup ‘GambOS Contributor’
gbWilly is in the usergroup ‘Blogger’

ask4nix said

Yes, I currently dual boot Manjaro and EndeavourOS, and I might move to Debian Trixie when it is released. None of these provide support for the qt-webkit. So I code in a Debian Bookwork KDE virtual machine (Gambas 3.18), then move the project to a Mint 21 (Gambas 3.19) virtual machine to create the AppImage. Both have Gambas updates set on hold. I know this goes against the best advice on the forum, but for the moment I have no practical alternative.
I'm running 3.19.6 on all my systems and will stay there for a while. Besides for myself I also make applications for a company I work for, and that is the main reason I never go with the latest Gambas version, as updates can unexpectedly cripple production environments by introducing new bugs. I even advise people using Gambas in company situations not use latest stable, so stuff keeps working.

So, the advise of 'running the latest version is the best advise' would certainly NOT be my opinion for company environments. For own hobby programming it's okay and for testing company software in, that you run in a lower version of Gambas, it's okay too IMHO. ;)

ask4nix said

The AppImage contains all the dependencies needed to run, but has some minor (annoying) inconsistencies in interface  font sizes  between different distros (even with the same desktop - in my case KDE Plasma ).  I can tweak it a bit by providing runtime options for interface fonts, but it's still not the best. However, I can live with that for the moment.
I know, that is because many factors have an influence on how things show on the screen, underlying toolkits, window managers, font types etc all influence the rendering of the end result.

ask4nix said

As for a replacement for the old qt-webkit, in addition to the current qt-webview, I think that the TextEdit and GridView/TableView controls are multi-line and html aware.  I'm not sure if they might also be 'not-so-easy-to-code' alternatives.
No idea what you are trying to achieve here, but you can put html in there, that is true. Another thing is gb.form.htmlview. But it can only show local html files. There is no mechanisms of retrieving a webpage for example, you will have to do that yourself and then show the local downloaded html file. It would give you the freedom of coding the underlying retrieval of html pages and show the in the form.htmlview.

All the best…

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#8
Banned
Maybe you can get JavaScript to do something similar?

document.elementFromPoint
Online now: No Back to the top
1 guest and 0 members have just viewed this.