Solved QTextBrowser tutorial?
-
Thank you @mrjj!
@mrjj said:
to catch when user click on such link use the anchorClicked signal
ala
connect(textBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(MyOwnSlot(QUrl)));I am already using these shenanigans for real (Internet) Urls, but I'm not sure I know much about these issues. If we use the example I described in the OP, how would you make "Blue" or "Green" urls (ie. blue and underlined) ? How would you manage to determine which Url is clicked ? (Is it "Blue"? Is it "Green"? etc.)
-
++If we use the example I described in the OP, how would you make "Blue" or "Green" urls (ie. blue and underlined) ?
Using the subset of html it supports.
try with
<font color="#0000FF">This will make your text blue.</font>++How would you manage to determine which Url is clicked ? (Is it "Blue"? Is it "Green"? etc.)
well you can string check the name. you get the url text so you must compared that as string. -
<a href="foo">bar</a>
Is foo or bar the url "name" or "text", as you called it?
-
@Pippin
well im not sure what will be in url.
just try it
i think foo.
but just make function and qDebug() it and see -
@mrjj Well if I put a quint32 as the url:
foo->append("<a href=" + ref + ">" + q_string + "</a>");
I never get
ref
back. When I run the slot:void MyInterface::openUrl(const QUrl& foo) const { std::cout << foo.url().toStdString() << std::endl; }
I print a character such as
R
orx
but never something like4144357970
. Also,foo.toString().toStdString()
gives the same result. -
hi
can you try to use use
foo->append("<a href=" + QString::number(ref) + ">" + q_string + "</a>");
as I have shot my foot off many times with + int + -
-
@Pippin
super. :)
i used to do that often myself as it do not complains so I forgot :) -
Just wondering, is it normal that such a QUrl (that is, a QUrl constructed with a quint32 alone) returns
true
whenQUrl::isValid()
is called? Because that's what I get and I don't understand why4144357970
is considered "valid." -
@Pippin said:
QUrl::isValid()
it says
"the URL is run through a conformance test. Every part of the URL must conform to the standard encoding rules of the URI standard for the URL to be reported as valid."So I do agree that its strange if isValid is true..
so I guess 4144357970 is following the rules. -
So far any quint32 that I tried is considered a "valid" url. Well since this thread is marked as solved, I'll make a new one.