rjschirmer
14th September 2009, 21:26
I am using QT Creator to create what I thought was a quick GUI application. I've narrowed down the problem to this:
QLineEdit lineGwIpAddr should contain an IP address entered by the user (i.e. "127.0.0.1"). Right now when I click QPushButton btnTest I want to validate the IP address QString as such:
void MainWindow::on_btnTest_clicked()
{
QHostAddress gatewayAddress();
if (gatewayAddress.setAddress(ui->lineGwIpAddr->text())) {
QMessageBox msgBox;
msgBox.setText("IP Address is OK");
msgBox.exec();
}
else {
QMessageBox msgBox;
msgBox.setText("Bad IP Address");
msgBox.exec();
}
}
setAddress(const QString & address) should return true if the string was able to be parsed. But when I build I get the following error:
.../imagedownload/mainwindow.cpp:22: error: request for member `setAddress' in `gatewayAddress', which is of non-class type `QHostAddress ()()'
It looks like it is not recognizing QHostAddress as a class. I have included networking in my project by adding QT += network in the project file, so I'm not sure why I am still getting this error.
I've attached the entire project to this post. Any help would be greatly appreciated.
QLineEdit lineGwIpAddr should contain an IP address entered by the user (i.e. "127.0.0.1"). Right now when I click QPushButton btnTest I want to validate the IP address QString as such:
void MainWindow::on_btnTest_clicked()
{
QHostAddress gatewayAddress();
if (gatewayAddress.setAddress(ui->lineGwIpAddr->text())) {
QMessageBox msgBox;
msgBox.setText("IP Address is OK");
msgBox.exec();
}
else {
QMessageBox msgBox;
msgBox.setText("Bad IP Address");
msgBox.exec();
}
}
setAddress(const QString & address) should return true if the string was able to be parsed. But when I build I get the following error:
.../imagedownload/mainwindow.cpp:22: error: request for member `setAddress' in `gatewayAddress', which is of non-class type `QHostAddress ()()'
It looks like it is not recognizing QHostAddress as a class. I have included networking in my project by adding QT += network in the project file, so I'm not sure why I am still getting this error.
I've attached the entire project to this post. Any help would be greatly appreciated.