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. Qt 5.3.2 / OSX 10.9+ draw in device RGB on multiple monitors

Qt 5.3.2 / OSX 10.9+ draw in device RGB on multiple monitors

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 507 Views
  • 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.
  • N Offline
    N Offline
    nils_heidorn
    wrote on last edited by
    #1

    Hi !
    I work on an Application that needs to draw specific device RGB colors
    to multiple monitors on OSX 10.9 using Qt 5.3.2.
    If i just draw a QColor(240,120,60) to a Widget, this is measured
    exactly as 240/120/60 on the primary monitor but if i create the same
    widget on a secondary monitor is is measured e.g. 240/117/51 .
    (One can use the Utility "Digital Color Meter" and be sure to switch to "native" values, if you choose sRGB or any of the other values the measurements will be identical or very close on the two monitors as this is the whole point of that unwanted magic).

    OSX tries to be smart ant to make the color on the second screen appear
    as the color on the primary screen. While this is nice its not usable
    for my Application.

    In former Qt / OSX versions we had this approach of subclassing a Widget and implementing the paintevent
    (c_ containg the current RGB Values to be painted e.g. 240/120/60):

    void RGBFrame::paintEvent(QPaintEvent* e)
    {
    CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
    float components[4] = { 1.0, 1.0, 1.0, 1.0 };
    components[0] = ((float)c_.red() * 1000 / 255) / 1000;
    components[1] = ((float)c_.green() * 1000 / 255) / 1000;
    components[2] = ((float)c_.blue() * 1000 / 255) / 1000;
    CGColorRef color = CGColorCreate (colorSpaceRef, components);
    CGRect cgrect = CGRectMake(e->rect().x(), e->rect().y(), e->rect().x() +
    e->rect().width(), e->rect().y() + e->rect().height());
    CGContextRef context = qt_mac_cg_context(this);
    CGContextSetFillColorWithColor(context, color);
    CGContextFillRect(context, cgrect);
    CGColorRelease(color);
    CGColorSpaceRelease(colorSpaceRef);
    }

    i tried to upgrade this to Qt5 using QMac::currentCGContext() instead of
    the no more available qt_mac_cg_context(this) but it simply does not work.

    Do you guys have a working or even more elegant approach ?

    Greetings & thank you,

    Nils Heidorn

    1 Reply Last reply
    0

    • Login

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