What you are asking for is impossible to do in the way you imagine it. openUrl() uses the operating system to specify the program to open the argument as mentioned in its documentation.
There might be some workarounds, but none of them will work well, or work on all browsers. It's just that this kind of fine-grained control is likely to be impossible for you.
If you want control of a tab in a browser, you could find the window represented by that tab and close it right before opening the new one. This solution is kind of hacky.
Another hacky solution is to find the HWND of the edit box holding the URL, and to try changing its text using SendMessage()
. This won't work on Chrome, however, as it does not use a separate control for the URL window. It might work on Firefox or IE.
The better solution is to make your own web browser you control using the Qt WebKit. It is pretty easy to render a page in it and change the url viewed. The QWebView is an easy to use implementation of the QtWebKit.
<meta http-equiv="refresh" content="5" >
in it and then overwriting this file on demand. But I did not try that yet and this approach probably has some downsides. – Ismtarget="something"
attribute. All Links with the same attribute value will open in the same tab / frame / window. I wasn't sure if there was a way to trigger the same thing programmatically. But I guess there's no way. – Jeremiah