unfortunately this also did not not work. same behaviour. textbrowser is cleared.
so i did the following:
- adding an anchor name to each link.
- in method 'follow_link(const QUrl&)' which is connected to
signal 'anchorClicked()' i set an empty url as source an scroll to the
named anchor:
part of the method which generates the html text which is shown in the textbrowser:
...
str += "<tr bgcolor=\"#dddddd\"><td>ID</td><td colspan=\"3\">";
str += "<a ";
str += "name=\"" + obj->ID() + "\" ";
str += "href=\"" + obj->ID() + "\">";
str += obj->ID() + "</a></td></tr>";
...
...
str += "<tr bgcolor=\"#dddddd\"><td>ID</td><td colspan=\"3\">";
str += "<a ";
str += "name=\"" + obj->ID() + "\" ";
str += "href=\"" + obj->ID() + "\">";
str += obj->ID() + "</a></td></tr>";
...
To copy to clipboard, switch view to plain text mode
this method gets an clicked link (which containes the ID of
an object) and opens a new widget.
void Object_Widget::followLink(const QUrl& url)
{
// textbrowser shows the same document but scrolls to the top
textBrowser_properties
->setSource
(QUrl());
// scroll to the link which was clicked
textBrowser_properties->scrollToAnchor(url.toString());
try {
model::Object& obj = model::System::object(url.toString());
model_gui::SingleObject_Widget* so =
new model_gui::SingleObject_Widget(0,Qt::WindowStaysOnTopHint);
so->object(&obj);
so->show();
} catch (model::NoSuchObject_Exception e) {
}
}
void Object_Widget::followLink(const QUrl& url)
{
// textbrowser shows the same document but scrolls to the top
textBrowser_properties->setSource(QUrl());
// scroll to the link which was clicked
textBrowser_properties->scrollToAnchor(url.toString());
try {
model::Object& obj = model::System::object(url.toString());
model_gui::SingleObject_Widget* so =
new model_gui::SingleObject_Widget(0,Qt::WindowStaysOnTopHint);
so->object(&obj);
so->show();
} catch (model::NoSuchObject_Exception e) {
}
}
To copy to clipboard, switch view to plain text mode
this works for me but getting rid of that automatic following of
links would be much better i think.
jh
Bookmarks