PDA

View Full Version : Need Help: from Visual C + + in QT



lucky_sever
4th April 2012, 15:26
There is a program written in Visual C + +, which binds to the USB-device and controls it. I need help in translating it on the QT. I recently switched to QT and scratching their heads for a week, but did not go well.


7560

wysota
4th April 2012, 15:31
And what exactly do you expect us to do?

lucky_sever
4th April 2012, 16:20
I look forward to your help, if not difficult, who can respond.

wysota
4th April 2012, 17:03
But what kind of help do you want? You don't want us to rewrite your MFC application in Qt for you, do you?

lucky_sever
4th April 2012, 17:57
Completely rewrite the application in QT, I am not asking you, because this one just for the deal will not happen. Although the code to comment on where and what classes are nuances in translation at the QT.

wysota
5th April 2012, 13:28
I have no idea what you mean or what you want, sorry. If you ask specific questions, I'm sure someone here will answer them but until you do that, we have no way of helping you.

Surendil
5th April 2012, 16:02
lucky_sever, you should start rewriting your app yourself, and in case of any difficulties you may ask for help in this thread. I'm not familar neither with MFC, nor USB devices, but if I could help you, I will :)

lucky_sever
8th April 2012, 22:17
How to implement this piece of code on QT?


#include <cstdlib>
#include <iostream>
#include <windows.h>
#include "AtUsbHid.h"

using namespace std;

int main(int argc, char *argv[])
{
HINSTANCE hLib = NULL;
hLib =LoadLibrary(AT_USB_HID_DLL);
if(hLib == NULL){
cout << "boing\n";
}
loadFuncPointers(hLib);

system("PAUSE");
return EXIT_SUCCESS;
}

This is what I got. The first part is executed, and the second (if (loadFuncPointers (lib) == NULL) {) shows the message "Not found USB HID address"



HINSTANCE hLib = NULL;
QLibrary lib(AT_USB_HID_DLL);
lib.load();
if (!lib.isLoaded())
{
QMessageBox::warning(this, tr("Error"),
tr("Not found AtUsbHid.dll"),
QMessageBox::Ok);
}
//************************************************** *********
if (loadFuncPointers(lib)==NULL) {
QMessageBox::warning(this, tr("Error"),
tr("Not found USB HID adress"),
QMessageBox::Ok);
}

d_stranz
8th April 2012, 22:39
Do you want us to implement it with or without your bugs? For example, in line 15 of your code, what happens if "hLib" is NULL? I bet you get more than "boing" when you call .

First, start by look at the Qt documentation and the Qt examples. That will show you how to write a basic "Hello World" program in Qt so you will know how QApplication and some of the other app-level classes are used. Next, to load an external DLL, look at QLibrary. To implement your call to system( "PAUSE" ), look at the QProcess::execute() method.

But don't expect anyone here to give you a working program. If you make a start and get stuck somewhere, we will help you. But we don't do homework assignments, and we don't help people who expect us to do everything for them before they try to do anything themselves. The Qt distribution has many example programs for all kinds of problems, and the Qt documentation has a large set of tutorials to help beginners get started. Learn to use them.

Added after 5 minutes:

Edit - our messages are crossing.

Since we have no idea what "loadFuncPointers()" is supposed to do, how can we tell you what is wrong? If you have not changed that function from your original Windows code, then it seems pretty obvious what might be wrong: QLibrary is not an HINSTANCE so if this function is expecting an HINSTANCE argument, no wonder it fails.

lucky_sever
9th April 2012, 07:58
The evil you have any!

wysota
10th April 2012, 16:44
Why do you want to rewrite this particular piece of code? If you are using WinAPI calls that work, why rewrite them?