daily pastebin goal
58%
SHARE
TWEET

Untitled

a guest May 16th, 2018 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. QPixmap map(":/Medal.jpg");
  2. QIcon ico(map);
  3. ico.addPixmap(map);
  4. QPushButton *p = new QPushButton;
  5. p->setIcon(ico);
  6. QString link = "http://www.google.com";
  7. QObject::connect(p, SIGNAL(clicked()),window,SLOT(QDesktopServices::openUrl(QUrl (link))));
  8.    
  9. #include <QApplication>
  10. #include <QDesktopServices>
  11. #include <QPushButton>
  12. #include <QUrl>
  13.  
  14. int main(int argc, char *argv[])
  15. {
  16.     QApplication a(argc, argv);
  17.     QPushButton p("Click me");
  18.     QString link = "http://www.google.com";
  19.     QObject::connect(&p, &QPushButton::clicked, [&link](){
  20.         QDesktopServices::openUrl(QUrl(link));
  21.     });
  22.     p.show();
  23.  
  24.     return a.exec();
  25. }
  26.    
  27. #include <QApplication>
  28. #include <QDesktopServices>
  29. #include <QPushButton>
  30. #include <QUrl>
  31. #include <functional>
  32.  
  33. int main(int argc, char *argv[])
  34. {
  35.     QApplication a(argc, argv);
  36.     QPushButton p("Click me");
  37.     QString link = "http://www.google.com";
  38.     QObject::connect(&p, &QPushButton::clicked, std::bind(QDesktopServices::openUrl, QUrl(link)));
  39.     p.show();
  40.  
  41.     return a.exec();
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top