Results 1 to 20 of 28

Thread: Discovery of printers in the network?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6

    Default Re: How to discover no of printers available in yourr network?

    Hi high_flyer,

    I have written code to show one of the available printer name ,I have used QLineText to show printer name
    but getting error in following part of code:

    Qt Code:
    1. void qprint::give_name_of_printer()
    2.  
    3. {
    4. QPrinterInfo PrinterInfo;
    5. QPrinter *printer=new QPrinter(QPrinter::ScreenResolution);
    6. //line no 33
    7. QList<QPrinterInfo> pinfo;
    8. //line 34
    9. QString str;
    10. pinfo= PrinterInfo.availablePrinters(); // transferring QList into temp list pinfo
    11. str=pinfo.value(1).printerName();//value function will return Qprinterinfo object at 2nd location & that object
    12. // is used get printer name & stored in CString object
    13. Name_edit->setText(str);//This is used to set text to printer name
    14.  
    15. }
    To copy to clipboard, switch view to plain text mode 





    I am getting error as incomplete type and cannot be defined 'class QList<QPrinterInfo>' at line no 33
    can you please help me out...

    Thanks
    Regards,
    Sumit
    Last edited by high_flyer; 25th May 2011 at 14:19. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to discover no of printers available in yourr network?

    Did you remember to #include the proper header file?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    surwassu (26th May 2011)

  4. #3
    Join Date
    May 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    6

    Default Re: How to discover no of printers available in yourr network?

    thanks alot........

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: How to discover no of printers available in yourr network?

    You also don't need to create an instance of QPrinterInfo (line 4) in order to use the static method QPrinterInfo::availablePrinters().

  6. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: How to discover no of printers available in yourr network?

    You code is fine, it will work, may be you missed to include <QList> file, just add it and any other file which is required, you should have it running.

    Tip:
    when you read the printer name, make sure the list contains the printers on the first hand, else your program will crash
    Qt Code:
    1. ...
    2. str=pinfo.value(1).printerName(); // this is not suggersted;
    3. ...
    4. if(pinfo.count() > n)
    5. str=pinfo.value(n).printerName();// get nth printer name
    6. ...
    To copy to clipboard, switch view to plain text mode 
    remember to post the code in code tags

  7. The following user says thank you to Santosh Reddy for this useful post:

    surwassu (26th May 2011)

Similar Threads

  1. QPrintDialog lists no printers
    By TMan in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2009, 15:33
  2. Discovery correct Language on all OS
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 25th February 2007, 19:27
  3. QSqlField discovery auto_increment int value
    By patrik08 in forum Qt Programming
    Replies: 6
    Last Post: 3rd December 2006, 11:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.