OK. I think that is the Qt problem because this WIN32 code works great (I have HP printer to):
@PRINTDLG pd;
ZeroMemory(&pd, sizeof(PRINTDLG));
pd.lStructSize = sizeof(PRINTDLG);
//pd.hwndOwner = m_hWnd;
pd.hDevMode = NULL;
pd.hDevNames = NULL;
pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC;
pd.nCopies = 1;
pd.nFromPage = 0xFFFF;
pd.nToPage = 0xFFFF;
pd.nMinPage = 1;
pd.nMaxPage = 0xFFFF;
if (!PrintDlg(&pd))
{
QMessageBox::warning(0,"Problem", "Cos z drukarka");
exit(0);
}
int LM = 0.5GetDeviceCaps(pd.hDC, LOGPIXELSX);
int TM = 0.5GetDeviceCaps(pd.hDC, LOGPIXELSY);
int LO = LM - GetDeviceCaps(pd.hDC, PHYSICALOFFSETX);
int RO = LM - (GetDeviceCaps(pd.hDC, PHYSICALWIDTH) - GetDeviceCaps(pd.hDC, PHYSICALOFFSETX) - GetDeviceCaps(pd.hDC, HORZRES));
int TO = TM - GetDeviceCaps(pd.hDC, PHYSICALOFFSETY);
int BO = TM - (GetDeviceCaps(pd.hDC, PHYSICALHEIGHT) - GetDeviceCaps(pd.hDC, PHYSICALOFFSETY) - GetDeviceCaps(pd.hDC, VERTRES));
if (LO<0) LO = 0;
if (RO<0) RO = 0;
if (TO<0) TO = 0;
if (BO<0) BO = 0;
int PW = GetDeviceCaps(pd.hDC, HORZRES) - (LO+RO);
int PH = GetDeviceCaps(pd.hDC, VERTRES) - (TO+BO);
qDebug() << "margins: " << LM << TM;
qDebug() << "offsets: " << LO << RO << TO << BO;
qDebug() << "width, height: " << PW << PH;
qDebug() << "width, height2: " << GetDeviceCaps(pd.hDC, HORZRES) << GetDeviceCaps(pd.hDC, VERTRES);
DOCINFO di;
di.cbSize = sizeof(DOCINFO);
di.lpszOutput = (LPTSTR)NULL;
di.fwType = 0;
StartDoc (pd.hDC, &di);
StartPage(pd.hDC);
// OUR RECTANGLE !!!
Rectangle(pd.hDC, LO, TO, LO+PW, TO+PH);
EndPage(pd.hDC);
EndDoc(pd.hDC);
DeleteDC(pd.hDC);@
Maybe the solution is in to mix WIN32 code with Qt?