Results 1 to 18 of 18

Thread: simple test connection

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: simple test connection

    Ok. simple example tcp connect to 80 port.

    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. ui->label->setText("");
    4. connect(mysocket,SIGNAL(connected()),this,SLOT(on_connected()));
    5. connect(mysocket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(on_error(QAbstractSocket::SocketError)));
    6. mysocket->connectToHost(ui->lineEdit->text(), 80);
    7. }
    8.  
    9. void MainWindow::on_error(QAbstractSocket::SocketError socketError)
    10. {
    11. ui->label->setText("Not connected " + QString::number(socketError));
    12. }
    13.  
    14. void MainWindow::on_connected()
    15. {
    16. ui->label->setText("It's ok. Connected");
    17. mysocket->disconnectFromHost();
    18. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

Similar Threads

  1. test my QT application
    By anand_2861985 in forum Installation and Deployment
    Replies: 1
    Last Post: 24th November 2010, 10:32
  2. Replies: 1
    Last Post: 2nd April 2010, 06:42
  3. A.I. test. A.I. test.
    By Kumosan in forum General Discussion
    Replies: 3
    Last Post: 19th October 2007, 19:19

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.