Question

I need to open some link (in my default browser) in a way similar to setOpenExternalLink on Qlabel, but by clicking on an item in the menu.

Is there some simple way? I think about using Qlabel with required link and use some action/event to pretend the click on it, meanwile the Qlabel was hidden.

Was it helpful?

Solution

Upon clicking the specific menu item (handled using your standard signals and slots) you could use openUrl(const QUrl &url) of QDesktopServices to have that link launch in your default browser.

As the documentation states, it will open

...the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.

So no need for fancy tricks with QLabels and the like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top