M
M
Mercury132021-05-18 08:31:44
Qt
Mercury13, 2021-05-18 08:31:44

How to get link rectangle in QTextBrowser?

In QTextBrowser, click on the link. I want to make a popup window, and for this I need to know WHERE to display this window.
I got the coordinates of the right slice of the link, but what to do next with them and how to get a full rectangle?

// vwInfo = QTextBrowser
void FmMain::on_vwInfo_anchorClicked(const QUrl &arg)
{
    // разбить по символу : на части — у меня урлы будут в виде pop_obj:OBJNAME
    auto str = arg.path().toStdString();
    auto things = str::splitSv(str, ':');
    if (things.size() < 2)
        return;

    // Get some parody for link rect
    // Unglitch: we don’t know how to get EXACT coords of link,
    // so improvise somehow
    auto rect = ui->vwInfo->cursorRect();
    rect.setLeft(rect.left() - 80);

    linkClicked(things[0], things[1], ui->vwInfo, rect);
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question