Open URL of an external browser when a button is clicked in a Qt application

My application should contain a button, which, when clicked on, should open an external browser, here is my code

void Logindialog::on_inscriptionPushButton_clicked() { QDesktopServices::openUrl(QUrl("http://www.google.com", QUrl::TolerantMode)); } 

but when I compile, I get this list of errors

  • error: incomplete type 'QUrl' used in the nested specifier
  • error: invalid use of incomplete type 'class QUrl'
  • error: forward declaration of class QUrl
+4
source share
1 answer

You forgot to enable QUrl because there is only a direct declaration.

Use either #include <QUrl> or #include <QtCore> at the top of the file.

+7
source

Source: https://habr.com/ru/post/1469449/


All Articles