Results 1 to 9 of 9

Thread: Problems with QActions and Pixmaps

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Angry Problems with QActions and Pixmaps

    I have a Sun machine that has 4 graphics cards each running 1 monitor for a total of 4 monitors. These machines are running in 8-bit colors to support some legacy code. The problem is I have 3 monitors showing identical GUIs but displaying different data inside the GUIs and the 4th window has a completely different GUI. I am constantly seeing a specific X Error and I have finally tracked it down to what specifically causes the errors. The error that prints to my terminal window looks like this:

    X Error: BadPixmap (invalid Pixmap parameter) 4
    Major opcode: 56 (X_ChangeGC)
    Resource id: 0xa80e26
    I noticed on that 1 unique GUI it would occur everytime I would gray something out and un-gray something. So whenever I changed the setEnabled( ) state of a QLabel or QSliderBar or QComboBox this error would pop up. I fixed this problem by telling the objects to hide and show instead of switching their enable states.

    On the 3 identical GUIs the errors occur on my QActions inside my QMainWindow's toolbars. A portion of the toolbar buttons are checkable. I have tried putting one set of checkable QActions into a QActionGroup and I have tried manually handling groups of checkable QActions instead of relying on a QActionGroup. Stuff behaves in the same manner whether they QActions are in a QActionGroup or not. Whenever I click on one of the checkable QActions I get 2 of these Bad Pixmap errors. I believe they show up because of the background of the button changes from an unchecked state to a checked state and the previously checked button changes from the checked state to an unchecked state. These errors also occur whenever I scroll over a checked QAction and then scroll over an unchecked QAction. I have tried taking out my QIcons I had for the buttons so they just displayed the QAction's text name but this did not fix any of the errors from popping up. I am using Qt 4.1.4 on Solaris 9 again in 8 bit color. I have a feeling if I could run this program in 24 bit color this would not be an issue but due to requirements, it is. Any help and ideas anyone may have would be greatly appreciated! Thanks so much!

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    My guess is the pixmaps that are drawn in the widget states you mentioned have bit depths greater than 8bpp.

    A way to be sure is to look up the error message in the X server sources. What version of X do you have? Is it the Sun version?

  3. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Problems with QActions and Pixmaps

    Quote Originally Posted by marcel
    My guess is the pixmaps that are drawn in the widget states you mentioned have bit depths greater than 8bpp.
    Is there a way to force the pixmaps drawn in the widget states to be less than a depth 0f 8 bits? My icons are just XBM files saved out as .h files so all the bits are either 1 or 0 since they are bitmaps. But it seems as if when you press the button and Qt tries to show it as being pressed in is when a bad color occurs doing like you said, giving that color in more than 8bpp. So is there a way to tell it you will be this color when pressed so I know the color is in my 8 bits?

    Quote Originally Posted by marcel
    What version of X do you have? Is it the Sun version?
    I do not know these off hand but will try to look. I am very unfamiliar with all the inner workings of Solaris and Linux and do not know what the X Server sources are. What are these and how might they be useful? Thanks!

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    Try using QBitmap
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    I was referring to the X server source code. This is available from www.X.org. My suggestion was to search for this error message in the sources to see exactly what is causing it to appear.

    But searching through those sources will be very hard .

    Better try first with QBitmap as high_flyer suggested, and see if it works like this.

    Regards.

  6. #6
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Re: Problems with QActions and Pixmaps

    Quote Originally Posted by high_flyer View Post
    Try using QBitmap
    I do not think I can use QBitmap because my items are QActions with their Icons being set to my bitmaps. These icons are QIcons and they can only be constructed from a QPixmap, QIcon, or QString filename. I believe I do not want to make a QPixmap because from what I have read, this will cause my icon to become 24 bit color which would definately cause me some problems. The icon itself is just a black line with the background staying the color of the window itself. So to me it seems the bitmap or icon is working fine it's just the color of the pressed in button which Qt appears to color itself. I have looked through QPalette but cannot find what in QPalette would allow me to change the color of a pressed in button. Any other ideas. I am getting ready to dig through these X source code. Thanks!

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    I believe I do not want to make a QPixmap because from what I have read, this will cause my icon to become 24 bit color which would definately cause me some problems.
    QBitmap is a QPixmap with 1bpp.
    So at least from the API point of view this should work.
    But I must admit I don't know how will the other icon states be rendered.
    Why not just try?
    Much easier than to dig through X code

    EDIT:
    The correct way to about rendering the other icon states (in case the defalut is not working for you) would be by implementing a custom
    QIconEngine, and not by fidling with X.
    This will also ensure your code will stay crossplatform.
    Last edited by high_flyer; 11th April 2007 at 16:23.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    The correct way to about rendering the other icon states (in case the defalut is not working for you) would be by implementing a custom
    QIconEngine, and not by fidling with X.
    The result of "fidling" with X would have been a clear understanding of why the error message appears in the first place. After that an exact solution could be proposed.

  9. #9
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,710
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problems with QActions and Pixmaps

    The result of "fidling" with X would have been a clear understanding of why the error message appears in the first place.
    Well, I don't see how looking at X code can tell you what you are doing wrong in your code.
    You could argue, that if you know which error is invoked in X, you can deduce from that what your app through Qt is passing to X.
    But you will need more luck than anything else to get any result using that path, IMHO.
    The error X is giving, is enough to know that you have a painting problem.
    I don't think you can get any more specific than that based on X output or code.

    The best policy of dealing with problems, is to avoid them in the first place.
    Avoiding problems is done by using the tools you have the right way.

    But, each is entitled to his won opinion
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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.