LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-23-2013, 01:11 AM   #1
fright
LQ Newbie
 
Registered: Nov 2012
Posts: 8

Rep: Reputation: Disabled
Error in passing parameters in function in Qt creator


Window.h
Code:
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include"dialog.h"



#include<fcntl.h>
#include<stdlib.h>
#include<sysexits.h>
#include<unistd.h>
#include<libelf.h>
#include<stdio.h>
#include<gelf.h>


namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT


public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
public slots:
       void openDialog();

private:
       Dialog *myDialog;

public slots:
    QString getPath();
 public slots:

    int libelfopen(QString path);
rivate:
    Ui::MainWindow *ui;

};

#endif // MAINWINDOW_H

WINDOW.cpp
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QtGui>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
 ui->setupUi(this);
 connect(ui->pushButton, SIGNAL(clicked()), this , SLOT(plus())) ;
connect(ui->pushButton_2,   SIGNAL(clicked()), this, SLOT(openDialog()) );
connect(ui->pushButton_3, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect(ui->pushButton_4, SIGNAL(clicked()), this ,SLOT(libelfopen(QString)));
}

MainWindow::~MainWindow()
{
    delete ui;
}

QString MainWindow ::getPath()
{
QString path;
    path = QFileDialog::getOpenFileName(
        this,
        "Choose a file to open",
        QString::null,
        QString::null);

   ui->lineEdit_4->setText(path );
 return path;
}

int MainWindow ::libelfopen(QString path)
{
int fd;

  fd= open(path.toUtf8().constData(), O_RDONLY, 0);

        
    if (fd < 0)
{

        ui->textEdit->setText("OPeni");
    }
return fd;

}

ERROR:

Starting /home/nawazbaig/calc-build-desktopQt_4_8_1_in_PATH__System__Release/calc...
QObject::connect: Incompatible sender/receiver arguments
QPushButton::clicked() --> MainWindow::libelfopen(QString)

/home/nawazbaig/calc-build-desktop-Qt_4_8_1_in_PATH__System__Release/calc exited with code 0
 
Old 01-25-2013, 03:31 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Your libelfopen() function requires a QString argument, which the clicked() signal does not give it - if it *were* to call libelfopen(), the string would be invalid/garbage.

You need to connect it to a function that takes no arguments and gets the path from somewhere else - presumably some QLineEdit somewhere.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in compiling ELF function in qt creator fright Programming 1 01-23-2013 12:09 AM
Passing parameters to bash script function (or subroutine) withanh Linux - Newbie 5 02-19-2012 08:54 AM
Passing data from interrupt handler function to tasklet function in kernel programmin double-out Programming 2 05-18-2010 10:10 PM
need help passing parameters in C++ hedpe Programming 1 10-21-2007 10:58 AM
A main can be changed by a function local without passing anything to the function? ananthbv Programming 10 05-04-2004 01:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration