Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] QPrinterInfo::availablePrinters() don't list available printers ?
Forum Updated to NodeBB v4.3 + New Features

[Solved] QPrinterInfo::availablePrinters() don't list available printers ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 6.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    max2g
    wrote on last edited by
    #1

    Hi !

    I spent some time on this problem and I want to share my solution here.

    I had a printer problem when deploying my QT application. In the production environment, my application is unable to get the list of available printers from QPrinterInfo::availablePrinters() and in the devlopment environment, everything is working fine !!!

    The cause of the problem is that my application is not able to find windowsprintsupport.dll ! The solution I found is to make sure I deploy the rigth windowsprintsupport.dll and to make sure that it can be found by the application !

    In my case, I deploy the wrong dll and even though I deploy a dll, it was not found by my application !!!

    Here is the detail about the solution I found !

    (1) QPrintInfo::availablePrinters() uses windowsprintersupport.dll.
    (2) However, in the QT folder, there are two such dll ! Which one must be used ?
    (3) The one that must be used is the following : C:\Qt\Qt5.2.0\5.2.0\mingw48_32\plugins\printsupport\windowsprintersupport.dll (which is about 41k).
    (4) The windowsprintersupport.dll (which is about 16k) in the following path must *not *be used : C:\Qt\Qt5.2.0\Tools\QtCreator\bin\plugins\printsupport\windowsprintersupport.dll since it is related to QTCreator.
    (5) Make sure you have the rigth one.
    (6) In your application, make sure you have the following instruction : qApp->addLibraryPath("./plugins"); This instruction allows your application to add a path to let the application find the dll.
    (7) In the project file (.pro), make sure to add printsupport to Qt, like the following instruction : QT += core gui sql xml webkitwidgets printsupport.
    (8) Find a machine where QT is not installed. This is to make sure that the deployed application will not find the Qt dll in the folder where Qt is installed and that we will be sure that the only place where .windowsprintersupport.dll is located is in the printsupport folder (see below).
    (9) Now, suppose you deploy your application in the following folder : c:\MyApp
    (10) In this folder, create a folder named "plugins" e.g. c:\MyApp\plugins
    (11) In c:\MyApp\plugins, create a folder named "printsupport" e.g. c:\MyApp\plugins\printsupport
    (12) In In c:\MyApp\plugins\printsupport, copy the windowsprintsupport dll.
    (13) Make sure that *all *other Qt dll needed by your application are also in the c:\MyApp folder
    (14) Test your application.

    Thank you !

    Max2G

    1 Reply Last reply
    2
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      Hi Max2G,

      Thanks for sharing your solution with us!

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • SprezzaturaS Offline
        SprezzaturaS Offline
        Sprezzatura
        wrote on last edited by
        #3

        Thanks! That solved my problem.

        I got it to work by putting the DLL in c:\MyApp\printsupport\ (no intermediate 'plugins' directory).

        Is this documented anywhere at qt.io?

        jsulmJ 1 Reply Last reply
        0
        • SprezzaturaS Sprezzatura

          Thanks! That solved my problem.

          I got it to work by putting the DLL in c:\MyApp\printsupport\ (no intermediate 'plugins' directory).

          Is this documented anywhere at qt.io?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Sprezzatura said in [Solved] QPrinterInfo::availablePrinters() don't list available printers ?:

          Is this documented anywhere at qt.io?

          Well, you have to deploy your app with all libs it needs. On Windows you can use https://doc.qt.io/qt-5/windows-deployment.html for that.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • SprezzaturaS Sprezzatura referenced this topic

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved