0

i am writing a program with Qt.I have class derived from QWidget.in it's constructor i want to use Linux Socket connect method .and also want to use Qt connect Signal & Slot method . how can i do this .because when i use Socket connect method compiler think i'm using Signal_Slot connect method and give compile error that argument doesn't match and ....

Thanks for any info you may be able to provide.

this is my code:

Login_Page::Login_Page(QWidget *parent) :
QWidget(parent),
ui(new Ui::Login_Page){

ui->setupUi(this);
ui->error_lablel->hide();
//try connect to server
...
if(connect(client_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))){
    ui->login_button->setDisabled(true);
    ui->error_lablel->setText("cannot connect to server");
    ui->error_lablel->show();
    while(true){
        if(!(connect(client_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))))
           break;
    }
    ui->login_button->setDisabled(false);
    ui->error_lablel->hide();
}

connect(ui->login_button,SIGNAL(clicked()),this,SLOT(login()));

}

2
  • Can you paste your error message?
    – Will
    Jun 1, 2014 at 13:41
  • error: no matching function for call to 'Login_Page::connect(int&, sockaddr*, unsigned int)'
    – aew
    Jun 1, 2014 at 14:06

1 Answer 1

2

Call the connect method of socket with :: prefix :

...
if(::connect(client_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))){
...
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.