PDA

View Full Version : how to make these contents work??



srohit24
2nd March 2009, 13:54
Hi

thanks for help so far.

I am trying to contact a dll through a Qt application and I have gone through the Qt documentation.

I have built a UI which has 2 push buttons and 1 text box. One push button is used to load the dll and copy its return value the other to paste the return value. The ui_dll.h contains the following.


/************************************************** ******************************
** Form generated from reading ui file 'dll.ui'
**
** Created: Mon Mar 2 18:19:03 2009
** by: Qt User Interface Compiler version 4.4.3
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
************************************************** ******************************/

#ifndef UI_DLL_H
#define UI_DLL_H

#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QPushButton>
#include <QtGui/QTextEdit>
#include <QtGui/QWidget>

QT_BEGIN_NAMESPACE

class Ui_Form
{
public:
QPushButton *pushButton;
QPushButton *pushButton_2;
QTextEdit *textEdit;

void setupUi(QWidget *Form)
{
if (Form->objectName().isEmpty())
Form->setObjectName(QString::fromUtf8("Form"));
Form->resize(384, 227);
pushButton = new QPushButton(Form);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(110, 30, 171, 23));
pushButton_2 = new QPushButton(Form);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
pushButton_2->setGeometry(QRect(110, 80, 171, 23));
textEdit = new QTextEdit(Form);
textEdit->setObjectName(QString::fromUtf8("textEdit"));
textEdit->setGeometry(QRect(110, 130, 171, 71));
pushButton->raise();
pushButton_2->raise();
textEdit->raise();

retranslateUi(Form);
QObject::connect(pushButton_2, SIGNAL(clicked()), textEdit, SLOT(paste()));

QMetaObject::connectSlotsByName(Form);
} // setupUi

void retranslateUi(QWidget *Form)
{
Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("Form", "Load DLL", 0, QApplication::UnicodeUTF8));
pushButton_2->setText(QApplication::translate("Form", "Paste the contents", 0, QApplication::UnicodeUTF8));
Q_UNUSED(Form);
} // retranslateUi

};

namespace Ui {
class Form: public Ui_Form {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_DLL_H


I have built a dll.cpp file. it has the following contents


QLibrary myLib("dllprog");
typedef void (*MyPrototype)();
MyPrototype TestDLL =
(MyPrototype) QLibrary::resolve("dllprog", "mysymbol");
if (TestDLL)
char a =TestDLL();
I still havent written the code to get the return value from the variable "a" and return it to the text box.

main.cpp has the following


#include "ui_dll.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget *widget = new QWidget;
Ui::Dll ui;
ui.setupUi(widget);

widget->show();
return app.exec();
}

I have built the .pro file as follows.


CONFIG += qt
FORMS += dll.ui
SOURCES += dll.cpp \
main.cpp


I would appreciate if you can help me complete the code and get the app working. I am new to Qt and finding it difficult at the moment. I have a working prototype which I built in VC++. I need a platform independent app and hence Qt.

what next should i do to built the app which can contact the dll and get the job done.??

spirit
2nd March 2009, 14:04
maybe this will help you (http://www.qtcentre.org/forum/f-newbie-4/t-dll-using-qt-17255.html/?highlight=QWidget)

srohit24
2nd March 2009, 15:02
thanks for replying. I have built my own dll.

What i need from my app is that it should contact the dll, get the return value(a string in this case) and show it in the text box.

how can this be accomplished?