Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Transparent window
Forum Updated to NodeBB v4.3 + New Features

Transparent window

Scheduled Pinned Locked Moved QML and Qt Quick
24 Posts 2 Posters 7.2k Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    Zubalama
    wrote on last edited by
    #1

    Hello guys is there a way to make a main Rectangle transparent I mean I want to see stuff behind the main window thank you

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Yes. Change opacity of the Rectangle and "setColor":http://doc.qt.io/qt-5/qquickwindow.html#color-prop of QQuickView to transparent.

      157

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zubalama
        wrote on last edited by
        #3

        does it depend on version? I mean I have Qt 2.4 max and can't see anything like that or do I need to import something?

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          Zubalama
          wrote on last edited by
          #4

          I mean could you give me a code for a main Rectangle that will be transparent I mean I'll be able to see through it

          1 Reply Last reply
          0
          • p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #5

            Sure, here you go:

            main.cpp
            @
            QQuickView view;
            view.setColor(Qt::transparent);
            view.setSource(QUrl(QStringLiteral("qrc:///main.qml")));
            view.show();
            @

            main.qml
            @
            import QtQuick 2.4

            Rectangle {
            width: 300
            height: 300
            color: "red"
            opacity: 0.1
            }
            @

            Hope this is what you meant..

            157

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              Zubalama
              wrote on last edited by
              #6

              https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpf1/v/t35.0-12/10943163_1556234467966068_1607147445_o.jpg?oh=593acee6bf7540fab8e38fbd548dee57&oe=54C47487&gda=1422184563_081860e0ec836656b3658b8563c24447 no it didn't help I just want to see whatever is behind it for e.g. this site or my desktop...

              1 Reply Last reply
              0
              • p3c0P Offline
                p3c0P Offline
                p3c0
                Moderators
                wrote on last edited by
                #7

                It seems you are using qmlscene to load the QML file, then you need to pass "--transparent" argument to it.

                157

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  Zubalama
                  wrote on last edited by
                  #8

                  am sorry but could you write me a code once more? with that last suggestion?

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #9

                    Are you using QtCreator to execute that file ?

                    157

                    1 Reply Last reply
                    0
                    • Z Offline
                      Z Offline
                      Zubalama
                      wrote on last edited by
                      #10

                      yes I'm using QtCreator

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #11

                        Then Keeping your current project selected, go to
                        QtCreator > Projects (On Left side pane) > Build & Run > Run > Run > Arguments

                        and add "--transparent" as argument there for qmlscene.

                        Note: There are two hypens for transparent, it appears to be combined after posting.

                        157

                        1 Reply Last reply
                        0
                        • Z Offline
                          Z Offline
                          Zubalama
                          wrote on last edited by
                          #12

                          What should I write in executable?

                          1 Reply Last reply
                          0
                          • p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #13

                            Which "executable" ?

                            157

                            1 Reply Last reply
                            0
                            • p3c0P Offline
                              p3c0P Offline
                              p3c0
                              Moderators
                              wrote on last edited by
                              #14

                              Here's a screenshot:

                              !http://i.imgur.com/PiTcIPc.jpg(Image)!

                              Check the highlighted part.

                              157

                              1 Reply Last reply
                              0
                              • Z Offline
                                Z Offline
                                Zubalama
                                wrote on last edited by
                                #15

                                https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpa1/v/t35.0-12/10947716_1556252631297585_1470867109_o.jpg?oh=05324a7b6cbff1fd5d4bf8d380ab3c10&oe=54C4A0F3&gda=1422186850_fc60db39f143bc07c6d644ac553a6e00 you mean this projects right? then build & run > run>run

                                1 Reply Last reply
                                0
                                • p3c0P Offline
                                  p3c0P Offline
                                  p3c0
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  Yes exactly. Just remove the double quotes.

                                  157

                                  1 Reply Last reply
                                  0
                                  • Z Offline
                                    Z Offline
                                    Zubalama
                                    wrote on last edited by
                                    #17

                                    oh no I meant to say that I want to see through it but like see that too for example I want to see that desktop but also I want to see whatever is written in this window

                                    1 Reply Last reply
                                    0
                                    • p3c0P Offline
                                      p3c0P Offline
                                      p3c0
                                      Moderators
                                      wrote on last edited by
                                      #18

                                      So what doesn't work for you ? If you have a Text element in this QML it will displayed as it is. It wont be affected by transparency.

                                      157

                                      1 Reply Last reply
                                      0
                                      • Z Offline
                                        Z Offline
                                        Zubalama
                                        wrote on last edited by
                                        #19

                                        https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpa1/v/t35.0-12/10939223_1556263367963178_1544022371_o.jpg?oh=16c8895a103701afce881a59cb81adbd&oe=54C47132&gda=1422166051_83ea345a38440bae9096d65ba7cb4658 this is what I see :S

                                        1 Reply Last reply
                                        0
                                        • p3c0P Offline
                                          p3c0P Offline
                                          p3c0
                                          Moderators
                                          wrote on last edited by
                                          #20

                                          It seems the Window itself has completely disappeared. Since I can't see it running in the task bar.

                                          Here is what it looks like on my machine:
                                          !http://i.imgur.com/8gLea96.jpg(Image3)!

                                          Kept the default Project template like yours and just added color and opacity for rectangle. In my case it is seen running in taskbar.

                                          157

                                          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