Results 1 to 8 of 8

Thread: Declarate global parameters

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Question Declarate global parameters

    Hi, I need to change some code from an internal method of Qt. I would like that it could access to an integer value and a file path saved in QString or in char string. How do you think that could be better to declare both parameters? As global variables, maybe? The problem is that I don't remember how to declare them and asign/consult the value.... Could you help me, please? Thanks.

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

    Default Re: Declarate global parameters

    What is the method? Is it virtual?

  3. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Declarate global parameters

    Quote Originally Posted by wysota View Post
    What is the method? Is it virtual?
    Is the internal method "addImage" from the file "qprintengine_pdf.cpp". The only way to change the code is by modifying the source file and rebuilding Qt. So, I need some global parameters...

  4. #4
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Declarate global parameters

    Hi again, let's see if I explain it a bit better. I need to pass two variables (one integer and one string) to the internal Qt method which I can't change its header. I've thought declaring global variables with extern but I dont' know if it would work. Another solution could be with some internal cache of Qt (like QPixmapCache) application-wide but I don't know if it exists. Could you suggest me something, please? I don't mind if it's a "dirty" solution because it's just a temporal fix

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

    Default Re: Declarate global parameters

    If you want a dirty solution, then simply copy and rename the whole class (or method, or a group of them) and make needed changes directly in that copy. You can then do with functions whatever you like. Just remember to call your changed version instead of Qt's aftrerwards.

  6. #6
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Declarate global parameters

    Yes wysota I had thought in that solution. The problem is that the method is not directly called but there's a bit trace before: QPainter -> QPrinter -> ??? -> addImage

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Declarate global parameters

    So make another flow. I understand you want to print to pdf and change the compression of images. First thing I would try is to download and check against snapshots of Qt4.3. As far as I know Trolltech planned to extend support for generating PDFs in Qt4.3 - maybe the part you want is already implemented.

    If that fails, then make your own PDF generator based on something else. I think you just need to implement your own paint engine which you can then feed to QPainter.

  8. #8
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Declarate global parameters

    Yes wysota I want to change the compression level. I will check the snapshots of Qt4.3. Thanks for the help.

Similar Threads

  1. Module to process application parameters
    By Opilki_Inside in forum General Programming
    Replies: 4
    Last Post: 8th February 2007, 23:26
  2. Creating a global array in my code???
    By therealjag in forum General Programming
    Replies: 5
    Last Post: 13th March 2006, 11:13

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.