My application requires me to obtain the first 7 characters from a window title strip. I've tried the following:

Qt Code:
  1. #include <QWidget>
  2. #include <windows.h>
  3.  
  4. HWND hChild;
  5. PTSTR pTitle;
  6. QString szTitle;
  7.  
  8. hChild = GetForegroundWindow();
  9.  
  10. pTitle = (PTSTR) malloc ( 8 * sizeof (QChar)) ;
  11.  
  12. int iFlag = GetWindowText( hChild, pTitle, 8);
  13. szTitle = *pTitle;
  14.  
  15. labelTitle->setText( szTitle);
To copy to clipboard, switch view to plain text mode 

While szTitle is a buffer of TCHAR, QString is unicode so I set the datatype to QString in line 6.

The above compiles, but line 12 returns 1 and line 15 only prints the first character in the title.

I tried changing line 6 to TCHAR, but then I get a compile error at line 15, "invalid conversion from TCHAR to char *.

An suggestions?