Forums

OverviewV-Play 2 Support (Qt 5) › Image transparency

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12611

    Kevin

    Hi, so I have my code something like this (modification of existing tutorial project “multiple scenes and multiple levels”)

    I am basically try to change the backbutton from a text based button to a transparent png icon instead.

    But for some reason the PNG icon transparency is not working and its showing up as an arrow with a square box around it.

    Is there something i need to do to allow “transparency” on an Image?

    MenuButton.qml

    Rectangle {
        id: button
    
    
        width: bg.width
        height: bg.height
    
        property alias bg: bg.source
    
        Image {
            id: bg
        }
    
    .....

     

    SelectLevelScene.qml

    import VPlay 2.0
    import QtQuick 2.0
    import "../common"
    
    SceneBase {
      id:selectLevelScene
    
      //.....
    
      MenuButton {
    
        bg: "../../assets/back.png"
        anchors.right: selectLevelScene.gameWindowAnchorItem.right
        anchors.rightMargin: 10
        anchors.top: selectLevelScene.gameWindowAnchorItem.top
        anchors.topMargin: 10
        onClicked: backButtonPressed()
      }
    }
    

     

    #12614

    Lorenz

    Hi Kevin,

    the transparency should work out of the box.

    The problem is that the rectangle which is enclosing your image has a color by the default. The fix is to add

    Rectangle {
      color: "transparent"
      ...
    }

    to your rectangle :)

    Please let me know if that helps.

    Cheers,

    Lorenz from V-Play

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support