Open link in default browser from Qtextbrowser
-
I search google to find this solution. but i was confused how to solve this problem.
In MainWindow.ui i drag & drop QTextBrowser. here i put someText where there is hyperlink. After compliling this application when i click this link this is not working.
I want it will open in my default browser like as firefox.
can u help me how to solve this problem?
is it something like -
@ui->textBrowser->openExternalLinks(default);@
but this code does not work.
-
Please tell us how it doesn't work: it gives you a compile error or how exactly isn't working, is default of type bool, because that function takes a bool parameter, if it is a bool make sure it's true when you call the function, or use: ui->textBrowser->setOpenExternalLinks(true); see the documentation "here":http://qt-project.org/doc/qt-4.8/qtextbrowser.html#openExternalLinks-prop
-
Check this, and see if it works:
@#include <QApplication>
#include <QTextBrowser>int main(int argc, char** argv)
{
QApplication a(argc, argv);
QTextBrowser tb;tb.setOpenExternalLinks(true); tb.setText("Link to <a >google.com</a> ... more text"); tb.show(); return a.exec();
}@
-
you need to set the text with QTextBrowser::setHtml() in order to open links.
Also links must be specified in a valid HTML syntax. -
raven-wrox, for me the setText works, but the a href should be properly formatted and the forum software seems to mess-up the format of the a href.
-second try:- not working, see example "here":http://www.w3schools.com/tags/att_a_href.asp -
[quote author="Zlatomir" date="1367075376"]the forum software seems to mess-up the format of the a href [/quote]
yea i thought so... i just wanted to mention that... so he doesn't copy-and-paste it and reports back that it's not working. -
[quote author="raven-worx" date="1367075504"]
yea i thought so... i just wanted to mention that... so he doesn't copy-and-paste it and reports back that it's not working.
[/quote]
I forgot to add a thank you, because i didn't notice that until after i read your post.