mainwindow.cpp Example File
annotatedurl/mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui/QDesktopServices>
#include <QtGui/QMouseEvent>
#include <QtCore/QUrl>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::displayAnnotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap)
{
ui->m_help->setHidden(true);
ui->m_url->setText(url.toString());
ui->m_title->setText(title);
ui->m_image->setPixmap(pixmap);
}
void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
if (ui->centralWidget->rect().contains(event->pos()))
QDesktopServices::openUrl(QUrl(ui->m_url->text()));
}