I have a situation here where I need to click on a link to navigate to another page . Something like Table of contents where in when you click on a line it takes you to the respective page. This is done using linkClicked() signal. It was working fine until I wrote a mousePressesEvent() and mouseReleaseEvent() for another requirement.
Now that the linkClicked() signal is superseded by the mouseEvent.
Kindly let me know how to make both work paralleling as I need both linkclick() signal incase of click on a link and mousePressEvent/mouseReleaseEvent in case of selecting the line.
Thankx
Added after 1 17 minutes:
I have written something like this. What I am trying to do here is on click and drag and release will show a highlight color options. Only on click , if HREF have to navigate to the respective page.
{
qDebug()<<"mouseMove : "<<mouseMove;
if(mouseMove)
{
if(!page()->selectedText().isEmpty())
{
p = event->screenPos();
QAction *highlightsAction
= contextMenu.
addAction("Highlights");
highlightsAction
->setIcon
(QIcon(":/images/highlightbox.png"));
QAction *notesAction
= contextMenu.
addAction("Annotaions");
notesAction
->setIcon
(QIcon(":/images/notesmenu.png"));
connect(notesAction, SIGNAL(triggered()), this, SLOT(createannotations()));
connect(highlightsAction, SIGNAL(triggered()), this, SLOT(createhighlight()));
QAction *selectedAction
= contextMenu.
exec(p
);
}
mouseMove = false;
}
else
{
qDebug()<<"I am gonna Emit";
connect(this
->page
(),
SIGNAL(linkClicked
(const QUrl
&)),
this,
SLOT(gotoLink
(QUrl)));
//emit linkClicked(url());
}
}
{
mouseMove = true;
}
void webview::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
qDebug()<<"mouseMove : "<<mouseMove;
if(mouseMove)
{
if(!page()->selectedText().isEmpty())
{
QMenu contextMenu;
p = event->screenPos();
QAction *highlightsAction = contextMenu.addAction("Highlights");
highlightsAction->setIcon(QIcon(":/images/highlightbox.png"));
QAction *notesAction = contextMenu.addAction("Annotaions");
notesAction->setIcon(QIcon(":/images/notesmenu.png"));
connect(notesAction, SIGNAL(triggered()), this, SLOT(createannotations()));
connect(highlightsAction, SIGNAL(triggered()), this, SLOT(createhighlight()));
QAction *selectedAction = contextMenu.exec(p);
}
mouseMove = false;
}
else
{
qDebug()<<"I am gonna Emit";
connect(this->page(), SIGNAL(linkClicked(const QUrl&)), this, SLOT(gotoLink(QUrl)));
//emit linkClicked(url());
}
}
void webview::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
mouseMove = true;
}
To copy to clipboard, switch view to plain text mode
I am unable to emit the signal for the href .
Added after 18 minutes:
In case of emitting the signal, I want to pass the url, if the point on which the click happened is href.
Bookmarks