Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open url on an external browser on button click in a Qt application

Tags:

c++

qt4

My application should contains a button which when you click on it an external browser should be opened 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 nested name specifier
  • error: invalid use of incomplete type 'class QUrl'
  • error: forward declaration of 'class QUrl'
like image 548
Ibrahim MAATKI Avatar asked Mar 15 '13 09:03

Ibrahim MAATKI


1 Answers

You forgot to include QUrl, as only a forward declaration exists.

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

like image 134
sanosdole Avatar answered Nov 15 '22 12:11

sanosdole