Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Display of QML image ignoring pixel alpha

    QML and Qt Quick
    image display alpha
    1
    2
    1621
    Loading More Posts
    • 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.
    • B
      bradg last edited by

      Hi. Fairly new to QT, but I've noticed that when I display an image where the source is a png file, the alpha for each pixel is ignored. Just where is displayed.

      From c++, I'm using QQuickView to load the source and display.

      Is there a setting somewhere to make this work?

      	Image
      	{
      		source: "image.png"
      	}
      
      1 Reply Last reply Reply Quote 0
      • B
        bradg last edited by

        I've figured this out. The problem wasn't in fact due to image files pixel alpha. That works just fine. It had to do with the QQuickView not being transparent. What I am doing is displaying a QQuickView as a borderless window to be used as a popup dialog and I want to see through to the background, where there are no objects in the qml file. (Think of a pop up dialog with rounded corners).

        Here's what I'm doing:

        	QQuickView view;
        
        	// don't display an icon in the task bar
        	// no border on the window
            view.setFlags(Qt::SubWindow | Qt::FramelessWindowHint);
        	
        	// make the view transparent so that the edges of the window,
        	// where there is no image, show through to the background
            QSurfaceFormat surfaceFormat;
            surfaceFormat.setAlphaBufferSize(8);
        
            view.setFormat(surfaceFormat);
            view.setClearBeforeRendering(true);
            view.setColor(QColor(Qt::transparent));
        
        	// load qml file and display
        	view.setSource(file.qml);
        	view.show();
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post