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. PickerColor in multiple displays context

PickerColor in multiple displays context

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 249 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.
  • DrAuraHxCD Offline
    DrAuraHxCD Offline
    DrAuraHxC
    wrote on last edited by
    #1

    bug_picker_color.png

    Hi,

    If you look at my screen configuration, I actually get the color, when I'm in the first blue area, of the second blue area. Kind of like if there's an overlap of the two screens... I use the QScreen::grabWindow method but I try hard to change the offsets, but it has no influence on the result...
    The black area means that when I walk with my mouse in this area, I get the color black... which is logical because for him, I'm outside the screen... but why...
    And for the screen on the far right, which is my secondary screen (in 1920), it works very well.
    For the coordinates that I get from the mouse, it is coordinates that consider the merging of the two screens.

    For those who want to test the behavior and have two screens, you can quickly make a MyWidget class derived from QWidget and override the mouseMoveEvent method for example like this :

    void
    MyWidget::mouseMoveEvent( QMouseEvent* event )
    {
        QPoint mousePosition = event->globalPos();
    
        QList< QScreen* > screens = QGuiApplication::screens();
        QColor color;
        for ( int i = 0; i < screens.count(); ++i )
        {
            if ( screens[i]->geometry().contains( mousePosition.x(), mousePosition.y() ) )
            {
                QPixmap pixmap = screens[i]->grabWindow( 0, mousePosition.x(), mousePosition.y(), 1, 1 );
                QImage image( pixmap.toImage() );
                color = image.pixelColor( 0, 0 );
            }
        }
    
        QPalette palette( color );
        setPalette( palette );
    
        QWidget::mouseMoveEvent( event );
    }
    

    If you have an idea on how to correctly retrieve the color under the mouse in a multi-screen context, I'm interested :)

    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