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. How to put a plus sign in the background of an app

How to put a plus sign in the background of an app

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 2.4k 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.
  • tomyT Offline
    tomyT Offline
    tomy
    wrote on last edited by tomy
    #1

    Hi all,

    At the first steps of reading about Qt Quick, I did this example. And this time I want to manipulate it a little.
    I want to put a big plus sign (+) on the background of the app, so that the bubble can stand on the middle of it when it's also in the middle of the page.

    I thought about it and did some tasks to get what I want. But when I run the app by Desktop kit, no sign of the plus mark (a row and a column) is shown.

    Would you please tell me the correct way of adding that "+" sign and have it work as needed?

    Thanks.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      inside MainForm { add

      Image {
      source: "PlusSign.svg"
      anchor.horizontalCenter = mainWindow.horizontalCenter 
      anchor.verticalCenter = mainWindow.verticalCenter
      width = mainWindow.width / 5
      height = width 
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • tomyT Offline
        tomyT Offline
        tomy
        wrote on last edited by tomy
        #3

        so firstly I need an XML file to define that sign, not?

        For example it's of the bubble (BTW, I made it a little bigger —r from 42 to 62):

        <?xml version="1.0"?>
        
         <svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
           <defs>
             <radialGradient id="grad1" cx="0.5" cy="0.7" r="0.7" fx="0.5" fy="0.4">
                <stop offset="0" style="stop-color:rgb(255,255,255)" />
                <stop offset="1.5" style="stop-color:rgb(0,102,153)" />
             </radialGradient>
           </defs>
           <circle cx="100" cy="80" r="62" fill="url(#grad1)"/>
         </svg>
        
        1 Reply Last reply
        0
        • tomyT Offline
          tomyT Offline
          tomy
          wrote on last edited by
          #4

          Do I need to create an XML file, say, named "PlusSign.svg" please?
          And is yes, how to do it so that it yields that Plus Sign for my app?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Schluchti
            wrote on last edited by Schluchti
            #5

            You don't need any XML. You can create a plus symbol either by drawing it yourself with QML or embedding a image of a plus symbol.

            For now, it's probably easier, if you go for the image approach, as it's slightly easier to accomplish.

            You basically need to to do the following:

            • get a image of a plus symbol
            • add that image to your resources file. (see the section "Adding Resources" here http://doc.qt.io/qtcreator/qtcreator-accelbubble-example.html)
            • Now you can use the code snippet that @VRonin provided you. (you may need to adapt the source name )

            Want to read more about Qt?

            https://gympulsr.com/blog/qt/

            Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

            VRoninV 1 Reply Last reply
            0
            • S Schluchti

              You don't need any XML. You can create a plus symbol either by drawing it yourself with QML or embedding a image of a plus symbol.

              For now, it's probably easier, if you go for the image approach, as it's slightly easier to accomplish.

              You basically need to to do the following:

              • get a image of a plus symbol
              • add that image to your resources file. (see the section "Adding Resources" here http://doc.qt.io/qtcreator/qtcreator-accelbubble-example.html)
              • Now you can use the code snippet that @VRonin provided you. (you may need to adapt the source name )
              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              @Schluchti said in How to put a plus sign in the background of an app:

              You don't need any XML

              Technically SVG is XML, the code posted above by @tomy , for example, is a circle with a 3D effect

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              S 1 Reply Last reply
              0
              • VRoninV VRonin

                @Schluchti said in How to put a plus sign in the background of an app:

                You don't need any XML

                Technically SVG is XML, the code posted above by @tomy , for example, is a circle with a 3D effect

                S Offline
                S Offline
                Schluchti
                wrote on last edited by
                #7

                @VRonin Should have taken a better look at it. Looked a bit like a XML layout at first glance. Sorry!

                Want to read more about Qt?

                https://gympulsr.com/blog/qt/

                Latest Article: https://gympulsr.com/blog/qt/2017/06/14/ios-background-music-qt.html

                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