Re: How can I solve this?
Hi,
Just get the return value into a QString and show it into the widget(QLineEdit, QTextEdit,...).
Re: How can I solve this?
can you explain it a bit further??
I have developed a console application but I am new to GUI and I have no idea how to add the signals and slots.
thanks for replying
Re: How can I solve this?
Hi,
You have a function called DLLfunction that returns a "char*", so:
DLLfunction retunrs a "char*" and QString uses it to create the QString.
Then, you have the main window where you execute your code:
Code:
myMainWindow::someMethod()
{
//Here you call your DLLfunction and show it to the QLineEdit
ui.LineEdit->setText(qString);
}
Take a look at "lineedit" examples on Qt dir.
Re: How can I solve this?
Code:
#include <QtGui/QApplication>
#include <QString>
#include <QLineEdit>
#include "dialog.h"
#include <QLibrary>
#include <iostream>
#include <windows.h>
using namespace std;
char DLLfunction()
{
typedef char* (*MyPrototype)();
MyPrototype myFunction =
(MyPrototype
) QLibrary::resolve("dllprog",
"TestDll");
char b = myFunction();
return b;
}
int main(int argc, char *argv[])
{
ui.LineEdit->setText(qString);
Dialog w;
w.show();
return a.exec();
}
this is my main.cpp code. This is the only page where I have written the code.
it says errors.
Quote:
error: invalid conversion from `char*' to `char'
error: `ui' was not declared in this scope
warning: unused variable 'ui'
Re: How can I solve this?
I think you should start looking at the examples and tutorials that are part of the Qt installation to know more about signal & slots and UI development using Qt. Qt Assistant has every thing that you need to get started.
Re: How can I solve this?
Code:
char DLLfunction()
{
typedef char* (*MyPrototype)();
MyPrototype myFunction =
(MyPrototype
) QLibrary::resolve("dllprog",
"TestDll");
char b = myFunction();
return b;
}
there is something weird in your code as define MyPrototype as raturning char* and than you do:
Code:
char b = myFunction();
where you are assigning returned value to one char. Is it right?
Re: How can I solve this?
a mistake.
the line now is
Code:
typedef char (*MyPrototype)();
Re: How can I solve this?
I need a GUI application to display the contents of myFunction. I have a working console application.
Code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLibrary>
#include <QLineEdit>
MainWindow
::MainWindow(QWidget *parent
){
ui->setupUi(this);
typedef char* (*MyPrototype)();
MyPrototype myFunction
= (MyPrototype
) QLibrary::resolve("dllprog",
"TestDll");
char* b = myFunction();
ui->lineEdit->setText(b);
}
MainWindow::~MainWindow()
{
delete ui;
}
This is my code display the characters that myFunction returns in a linedit.
I have created a pushButton and a lineEdit in the .ui file.
I am getting this error.
Quote:
:-1: error: collect2: ld returned 1 exit status
How can i solve this?
thanks for reading.