Results 1 to 3 of 3

Thread: QHostAddress

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QHostAddress

    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:

    Qt Code:
    1. void MainWindow::on_btnTest_clicked()
    2. {
    3. QHostAddress gatewayAddress();
    4.  
    5. if (gatewayAddress.setAddress(ui->lineGwIpAddr->text())) {
    6. QMessageBox msgBox;
    7. msgBox.setText("IP Address is OK");
    8. msgBox.exec();
    9. }
    10. else {
    11. QMessageBox msgBox;
    12. msgBox.setText("Bad IP Address");
    13. msgBox.exec();
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Attached Files Attached Files

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.