UrlPushButton.cpp 426 B

1234567891011121314151617181920212223242526
  1. #include "UrlPushButton.hpp"
  2. #include <QDesktopServices>
  3. #include "moc_UrlPushButton.cpp"
  4. void UrlPushButton::setTargetUrl(QUrl url)
  5. {
  6. setToolTip(url.toString());
  7. m_targetUrl = url;
  8. }
  9. QUrl UrlPushButton::targetUrl()
  10. {
  11. return m_targetUrl;
  12. }
  13. void UrlPushButton::mousePressEvent(QMouseEvent *event)
  14. {
  15. Q_UNUSED(event)
  16. QUrl openUrl = m_targetUrl;
  17. if (openUrl.isEmpty())
  18. return;
  19. QDesktopServices::openUrl(openUrl);
  20. }