Hello,
Has anyone an idea on how to convert a DWORD to a QSTRING to display in a lineEdit?
Thanks
Hello,
Has anyone an idea on how to convert a DWORD to a QSTRING to display in a lineEdit?
Thanks
A DWORD is a typedef for unsigned long in Microsoft headers. Look at the QString::arg() or the QString::number() variants. How do you want to display it?
I want to display it in a QLineEdit. I have a DWORD variable MPUSBGetDLLVersion and I want to display it just like this:
QLineEdit *lineEdit;
lineEdit = new QLineEdit;
lineEdit->setText(MPUSBGetDLLVersion);
but I need to convert the MPUSBGetDLLVersion to a QString first.
I'll take a look at the QString::arg() and the QString::number() variants.
Added after 58 minutes:
Ok, I write the code like this now:
Qt Code:
DWORD temp = MPUSBGetDLLVersion();To copy to clipboard, switch view to plain text mode
When I display it I am getting the value MPUSBAPI Version:257.0 instead of MPUSBAPI Version:1.0. Anyone knows what I am doing wrong?
Last edited by digog; 8th November 2010 at 05:17.
From a quick Google it seems the version number is typically output in hexadecimal:
http://www.microchip.com/forums/m346499-print.aspx
in this case:Qt Code:
temp = MPUSBGetDLLVersion(); cout << "DLL Version => " << std::hex << temp << endl;To copy to clipboard, switch view to plain text mode
This version number may not be in any way related to the user-visible version number the DLL (i.e. the one you see in the Windows Properties panel).
Last edited by ChrisW67; 9th November 2010 at 02:06.
Thanks, problem resolved. the code now is:
Qt Code:
DWORD temp = MPUSBGetDLLVersion(); int aux1 = HIWORD(temp)>>8; int aux2 = HIWORD(temp) & 0xFF; int aux3 = LOWORD(temp)>>8; int aux4 = LOWORD(temp) & 0xFF; To copy to clipboard, switch view to plain text mode
And it displays MPUSBAPI Version:1.1.0.0
I was using a new version of the dll and didn't know before.
Bookmarks