How to use QPrinterInfo()?

259 views
Skip to first unread message

Jonce

unread,
Mar 22, 2016, 7:21:21 AM3/22/16
to qtcon...@googlegroups.com
​Hi All,

new to hbqt​, i'm tracing hbqtbrowse.prg
call method print(<my default printer name in windows>)

METHOD HbQtBrowse:print( cPrinter, lOpenPrintDialog )

       .....
      ​​
oPrinterInfo := QPrinterInfo(cPrinter)
​      oList := oPrinterInfo:availablePrinter()

         // or ​oPrinterInfo:availablePrinterNames()
 
as qt document recommand
​      ​
​my​M
​s​
ginfo(
​Str(​
​​
oList:size
​​
()))
​​       ....
​always show 0
(there are 2 printers in windows control panel)

test on
windows xp sp3, windows server 2003, windows 8.1 x64
QtContribs_Mingw-492_Qt-550_r417_Setup.exe


What did I do wrong?

Regard
jonce
Message has been deleted

Luigi Ferraris

unread,
Mar 22, 2016, 12:52:35 PM3/22/16
to qtcon...@googlegroups.com
Il 22/03/2016 12.21, Jonce ha scritto:
new to hbqt​, i'm tracing hbqtbrowse.prg
Welcome on board!
call method print(<my default printer name in windows>)

METHOD HbQtBrowse:print( cPrinter, lOpenPrintDialog )

       .....
      ​​
oPrinterInfo := QPrinterInfo(cPrinter)
​      oList := oPrinterInfo:availablePrinter()

         // or ​oPrinterInfo:availablePrinterNames()
 
as qt document recommand
​      ​
​my​M
​s​
ginfo(
​Str(​
​​
oList:size
​​
()))
​​        ....
​always show 0
(there are 2 printers in windows control panel)
First of all, I will assume you have 2 printers installed and they can be viewed from other programs... else there is some problem ;-)

I remember this problem can be related with plugin "windowsprintersupport.dll" that is not found or not loaded or wrong (pay attention do not mix Qt .dlls).
So, check if this .dll is available e.g.
a) in your program directory (e.g. <yourDir>/plugins/printsupport/windowsprintersupport.dll)
OR
b) if you have a good qt.conf file to link the right plugins directories; next is an example of qt.conf
[Paths]
Plugins=<yourQtDir>/plugins
Translations=<yourQtDir>/translations

Regards
Luigi Ferraris



Jonce

unread,
Mar 22, 2016, 5:29:49 PM3/22/16
to qtcon...@googlegroups.com
Hi Luigi,

Yes, the 3 windows pc work fine with printers by harbour + fiveiwn.
now I want to use hbqt for utf8 and crossing platform.

I can't find windowsprintersupport.dll in <qcontrib 417>\bin.

But I found Q5PrintSupport.dll.
Is this the same file for  QT 5.50 that 417 built-in?

Regards
 

--
You received this message because you are subscribed to the Google Groups "QtContribs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtcontribs+...@googlegroups.com.
To post to this group, send email to qtcon...@googlegroups.com.
Visit this group at https://groups.google.com/group/qtcontribs.
For more options, visit https://groups.google.com/d/optout.

Jonce

unread,
Mar 23, 2016, 12:46:46 AM3/23/16
to qtcon...@googlegroups.com
Hi Luigi,

I found windowsprintersupport.dll (40 KB 2015/4/23) from Marinas-GUI 3.05

and copied it to both <qcontrib 417>\bin and <my app>\plugins\printsupport

oList:size() is still 0 (zero)

Did you sucess in <qcontrib 417> ?

BR

Luigi Ferraris

unread,
Mar 23, 2016, 9:28:51 AM3/23/16
to qtcon...@googlegroups.com
Il 23/03/2016 5.46, Jonce ha scritto:
Hi Luigi,

I found windowsprintersupport.dll (40 KB 2015/4/23) from Marinas-GUI 3.05

and copied it to both <qcontrib 417>\bin and <my app>\plugins\printsupport

oList:size() is still 0 (zero)

Did you sucess in <qcontrib 417> ?

BR

Hi Jonce,
you can find that file in your Qt installation; remember, important: in your Qt installation. I suggest to you, to build QtContribs and Harbour (or Marinas, I don't know) using the same tool chain (C compiler/linker) as you Qt installation.

e.g. Qt. 5.5.0 <yourMainQtPath>/Qt5.5.0/5.5/mingw492_32/plugins
e.g. Qt. 5.5.1 <yourMainQtPath>/Qt5.5.1/5.5/mingw492_32/plugins
e.g. Qt. 5.6.0 <yourMainQtPath>/Qt5.6.0/5.6/mingw49_32/plugins

about file: you have (more or less) to options
a) copy this file in your <myApp>/plugins/printsupport/<file.dll>; try also <myApp>/printsupport/<file.dll> I don't remember well
b) using a qt.conf to set the path.

For the moment, try a) option

I will investigate on my PC; ASAP I will inform you

Regards
Luigi

Luigi Ferraris

unread,
Mar 23, 2016, 10:18:50 AM3/23/16
to qtcon...@googlegroups.com
Il 23/03/2016 5.46, Jonce ha scritto:
Hi Luigi, .....
Well, I have tested. My environment is
- WinXp
- Qt 5.6.0
- QtContribs 425 (I think there is no problem using 417)
- I built Harbour and QtContribs using distribuited Qt C tool (MinGw)

I have used this simple CLIPPER procedure code in my source
STATIC PROCEDURE udfCheck()
   LOCAL oPrinterInfo
   LOCAL oList
   LOCAL nP
   oPrinterInfo := QPrinterInfo()
   oList := oPrinterInfo:availablePrinterNames()
   hb_trace( HB_TR_ALWAYS, "size " + hb_NtoS( oList:size() ) )
   FOR nP := 0 TO oList:size()-1
      hb_trace( HB_TR_ALWAYS, "# " + hb_NtoS( nP ) + " name >" + oList:at( nP ) )    
   NEXT nP
RETURN

n.b. as Qt write in documents: it is NOT recommended to use availablePrinters()

And it gives to me this output tracing (where oop1.prg is the source program)
oop001.prg:66:UDFCHECK(): HB_TR_ALWAYS size 5
oop001.prg:70:UDFCHECK(): HB_TR_ALWAYS # 0 name >Microsoft XPS Document Writer
oop001.prg:70:UDFCHECK(): HB_TR_ALWAYS # 1 name >HP LaserJet 4050 Series PCL 6
oop001.prg:70:UDFCHECK(): HB_TR_ALWAYS # 2 name >doPDF 8
oop001.prg:70:UDFCHECK(): HB_TR_ALWAYS # 3 name >Canon MP630 series Printer
oop001.prg:70:UDFCHECK(): HB_TR_ALWAYS # 4 name >Automatico HP LaserJet 4050 Series PCL6 su SERVERTA

As you can see 5 is returned, but you must start from 0 (zero) to :size()-1; remember difference between C and Harbour

I assume your program directory is <your_app_directory> (e.g. can be harbour/bin but I think it's not good to be used); I have used these .dll installed as belowe

<your_app_directory>\libEGL.dll
<your_app_directory>\libgcc_s_dw2-1.dll
<your_app_directory>\libGLESv2.dll
<your_app_directory>\libstdc++-6.dll
<your_app_directory>\libwinpthread-1.dll
<your_app_directory>\opengl32sw.dll
<your_app_directory>\Qt5Core.dll
<your_app_directory>\Qt5Gui.dll
<your_app_directory>\Qt5Network.dll
<your_app_directory>\Qt5PrintSupport.dll
<your_app_directory>\Qt5Svg.dll
<your_app_directory>\Qt5Widgets.dll
<your_app_directory>\plugins\iconengines\qsvgicon.dll
<your_app_directory>\plugins\imageformats\qdds.dll
<your_app_directory>\plugins\imageformats\qgif.dll
<your_app_directory>\plugins\imageformats\qicns.dll
<your_app_directory>\plugins\imageformats\qico.dll
<your_app_directory>\plugins\imageformats\qjpeg.dll
<your_app_directory>\plugins\imageformats\qsvg.dll
<your_app_directory>\plugins\imageformats\qtga.dll
<your_app_directory>\plugins\imageformats\qtiff.dll
<your_app_directory>\plugins\imageformats\qwbmp.dll
<your_app_directory>\plugins\imageformats\qwebp.dll
<your_app_directory>\plugins\platforms\qminimal.dll
<your_app_directory>\plugins\platforms\qoffscreen.dll
<your_app_directory>\plugins\platforms\qwindows.dll
<your_app_directory>\plugins\printsupport\windowsprintersupport.dll
<your_app_directory>\plugins\translations\qt_it.qm

I hope can you solve your problem.

Regards
Luigi


Jonce

unread,
Mar 23, 2016, 7:36:00 PM3/23/16
to qtcon...@googlegroups.com
​​
Hi Luigi,

I registed a qt account for downloading
qt-opensource-windows-x86-mingw492-5.5.0.exe
After try and try more than 3 hours,
Many times install qt and  coping .dll files.
Finally it works.~ Yes  oList:size() RETURN 2 NOW!
Thanks a lot!

Those copies were failed  'case there are many <plugins >dir under qt dir
Unless from the right directory you point out:
"<QtPath>/Qt5.5.0/5.5/
mingw492_32/plugins"

​​


​Regards​

Jonce

unread,
Mar 23, 2016, 7:45:40 PM3/23/16
to qtcon...@googlegroups.com
Another little question.
Where is the file and name  hb_trace() wrote?

Luigi Ferraris

unread,
Mar 25, 2016, 12:02:56 PM3/25/16
to QtContribs
Hi Jonce,
I'm glad you solve problem.
Yes, under Qt there are many plugins but (normally) you can copy only what you need. Referring to previous list, they can be considered the "minimum required". You can tray windeployqt (see internet) to create your list.

About hb_trace is the Harbour tracing system; from my pov, a powerful way to debug your programs because it does not interfere with the GUI world in particular with the award or loss of focus on widgets.

To be used you need
1) add #include "hbtrace.ch" to your program
2) you must use a .bat to run program; more or less like this one:
@ECHO OFF

SET SAVE_PATH=%PATH%
SET QTDIR=%CD%/../../../qtshared/sharedll
SET PATH=%QTDIR%;%PATH%

SET HB_TR_LEVEL=DEBUG
SET HB_TR_SYSOUT=Y
SET HB_TR_WINOUT=1
SET HB_TR_OUTPUT=hb_trace.log

START "title" /D%CD% /B "<your.exe"

SET HB_TR_LEVEL=
SET HB_TR_SYSOUT=
SET HB_TR_WINOUT=
SET HB_TR_OUTPUT=

SET PATH=%SAVE_PATH%
SET SAVE_PATH=
SET QTDIR=


In bold I marked what you need to create a file named hb_trace.log. You can read file when program will be closed: not before.
Other settings... I'm using a shared folder where I put all Qt dll required; it's a way to avoid having dll everywhere.

Regards
Luigi


--
You received this message because you are subscribed to the Google Groups "QtContribs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtcontribs+...@googlegroups.com.
To post to this group, send email to qtcon...@googlegroups.com.
Visit this group at https://groups.google.com/group/qtcontribs.
For more options, visit https://groups.google.com/d/optout.



--
Luigi Ferraris
www.l3w.it

Jonce

unread,
Mar 25, 2016, 12:45:39 PM3/25/16
to qtcon...@googlegroups.com
Hi Luigi,

Thanks, help a lot.


The most helpful is qt.conf,
Before, one app.exe I need to copy a set of <qt.dlls + platforms\*.dll>
now I just need one for all qt apps with the qt.conf on a single machine

Regards
Reply all
Reply to author
Forward
0 new messages