Results 1 to 2 of 2

Thread: Negative border offset CSS in windows generates error

  1. #1
    Join Date
    Dec 2011
    Posts
    27
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Negative border offset CSS in windows generates error

    Hi all, I'm having an issue with a discrepancy between Windows and OSX in stylesheet (QSS) handling.

    Namely, for QSlider-derived widgets, using the 'border-image' property requires me to have a negative border offset for the image to ensure that my custom handle is positioned correctly relative to the border image. Without negative border offsets, the handle is drawn inside the groove (both groove and handle have same heights, but groove has greater width than the range of the handle), and does not look as I intend it to. With a negative border offset, the handle is drawn relative to the groove as intended, but generates the following errors on windows (with crash on some widgets) :

    Qt Code:
    1. QPainter::drawPixmapFragments - the source rect is not contained by the pixmap's rectangle
    2. ASSERT: "v1 >= 0 && v1 < max" in file painting\qdrawhelper.cpp, line 734
    3. Invalid parameter passed to C runtime function.
    To copy to clipboard, switch view to plain text mode 

    It does not generate an errors on OSX, and works as expected there.

    Here is the offending QSS:

    Qt Code:
    1. SlideToggle::groove:horizontal {
    2. border-image: url(:/core/toggle-bg.png);
    3. /* border-left: -9px transparent;
    4.  border-right: -8px transparent;
    5.  border-bottom: -5px transparent;
    6.  border-top: 0px transparent;*/
    7. border: 0px transparent;
    8. padding: 0px;
    9. margin: 0px;
    10. }
    11.  
    12. SlideToggle::handle:horizontal {
    13. margin:0px;
    14. padding:0px;
    15. image: url(:/core/slider-handle-dark.png);
    16. }
    17.  
    18. SlideToggle {
    19. margin:4px;
    20. }
    To copy to clipboard, switch view to plain text mode 

    Un-commenting the commented code generates a crash 100% of the time on Windows 7, using Qt 4.8.0.

    I intend to re-design this element that causes the crash to use something other than a slider (like a QButton, since it only has two states), which is no big deal, but I have other sliders that have required negative offsets (for example, drop-shadows below or above groove) that generate thousands of warnings at run-time using them. Is there any ability to change the relationship between the groove border image and the handle that won't generate these problems on Windows?

    Thanks in advance!

  2. #2
    Join Date
    Dec 2011
    Posts
    27
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Negative border offset CSS in windows generates error

    ... just a follow-up:

    Negative border offsets cause crashes in Windows, and appear to be a bad idea in general, even if they are quite effective in placing on OSX (and I've seen a few references to using them with sliders here on the forum). But, it looks that in Windows the same effect can be created by specifying a negative margin for the handle as long as height and width are specified, e.g.:

    Qt Code:
    1. SlideToggle::groove:horizontal {
    2. border-image: url(img/toggle-bg.png);
    3. padding: 0px;
    4. margin: 0px;
    5. height: 35px;
    6. width: 75px;
    7.  
    8. }
    9.  
    10. SlideToggle::handle:horizontal {
    11. margin:-2px -4px -4px -4px;
    12. padding:0px;
    13. height: 42px;
    14. width:42px;
    15. image: url(img/slider-handle-dark.png);
    16. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QWebView print() generates huge PDF files on Windows
    By brush.tyler in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2012, 15:01
  2. Replies: 1
    Last Post: 20th September 2012, 17:12
  3. Replies: 2
    Last Post: 21st March 2012, 15:30
  4. negative border radius style sheet
    By matteo.ceruti in forum Qt Programming
    Replies: 0
    Last Post: 23rd December 2011, 15:19
  5. Border radius unix/windows
    By dacrawler in forum Newbie
    Replies: 2
    Last Post: 23rd January 2011, 14:27

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.