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 Achieve Scrolling marquee using qml

How to Achieve Scrolling marquee using qml

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 4 Posters 7.2k 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.
  • I Offline
    I Offline
    imxiangpeng
    wrote on 6 Dec 2010, 03:34 last edited by
    #1

    I want to achieve the effect whick liking scroll marquee in webpage(html), does someone have some suggest?

    1 Reply Last reply
    0
    • X Offline
      X Offline
      xsacha
      wrote on 6 Dec 2010, 04:12 last edited by
      #2

      This works fine here:

      @
      import QtQuick 1.0
      import QtWebKit 1.0

      WebView {
      width: 200; height: 30
      html: "<marquee>GOOG 544.59 (+95.05) | TWX 14.88 (+0.27) | IBM 124.96 (+1.88)</marquee>"
      }
      @

      Edit:

      You can achieve the same thing in JavaScript, if you do not want to use marquee. JavaScript allows a little more manipulation, such as this:

      @

      import QtQuick 1.0
      import QtWebKit 1.0

      WebView {
      width: 200; height: 100
      html: "[removed]\n" +
      "var marqueecontent='<p>GOOG 544.59 (+95.05)</p><p>TWX 14.88 (+0.27)</p><p>IBM 124.96 (+1.88)</p>'\n" +
      "var cross_marquee, cross_marquee2\n" +

            "function populate(){\n" +
                "cross_marquee= document.getElementById(\"iemarquee\")\n" +
                "cross_marquee2= document.getElementById(\"iemarquee2\")\n" +
                "cross_marquee2[removed]=cross_marquee[removed]=marqueecontent\n" +
                "cross_marquee2.style.top=(parseInt(cross_marquee.style.top)+105)+\"px\"\n" +
                "lefttime=setInterval(\"scrollmarquee()\",16)\n" +
            "}\n" +
            "window.onload=populate\n" +
      
            "function scrollmarquee(){\n" +
                "if (parseInt(cross_marquee.style.top)<-105)\n" +
                "cross_marquee.style.top=105+\"px\"\n" +
                "if (parseInt(cross_marquee2.style.top)<-105)\n" +
                "cross_marquee2.style.top=105+\"px\"\n" +
                "cross_marquee2.style.top=parseInt(cross_marquee2.style.top)-1+\"px\"\n" +
                "cross_marquee.style.top=parseInt(cross_marquee.style.top)-1+\"px\"\n" +
            "}\n" +
      
            "with (document){\n" +
                "write('<div style=\"position:relative;width:'+200+';height:'+100+';overflow:hidden\">')\n" +
                "write('<div id=\"iemarquee\"  style=\"position:absolute;top:0px;\"></div>')\n" +
                "write('<div id=\"iemarquee2\" style=\"position:absolute;\"></div>')\n" +
                "write('</div>')\n" +
            "}\n" +
            "[removed]"
      

      }
      @

      The [removed] are script type "javascript"

      Edit: Thread is closed, but for future readers, I'll mention in reply to blam:
      You can use QML objects within the HTML code if you want.

      • Sacha
      1 Reply Last reply
      0
      • B Offline
        B Offline
        blam
        wrote on 6 Dec 2010, 07:32 last edited by
        #3

        Do you mean you want to implement a scrolling marquee within a web page in QML, or do you want to take the scrolling marquee effect from html and apply it in QML?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fcrochik
          wrote on 6 Dec 2010, 16:43 last edited by
          #4

          Thread is closed? What does it mean?

          Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

          1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on 6 Dec 2010, 16:47 last edited by
            #5

            [quote author="fcrochik" date="1291653792"]Thread is closed? What does it mean?[/quote]

            When a thread is closed, you cannot post new replies to it. this seems still open :)

            1 Reply Last reply
            0
            • F Offline
              F Offline
              fcrochik
              wrote on 6 Dec 2010, 16:54 last edited by
              #6

              That is what I imagined... Don't think I came across any yet... Just added a suggestion to allow to use for "closed" or "open" as a search criteria and also display status (open or closed) on search results.

              Certified Specialist & Qt Ambassador <a href="http://www.crochik.com">Maemo, Meego, Symbian, Playbook, RaspberryPi, Desktop... Qt everywhere!</a>

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xsacha
                wrote on 7 Dec 2010, 00:25 last edited by
                #7

                Uh, this was definitely closed! I couldn't reply. Don't know why it was closed as I was expecting a reply by OP.

                But, as blam says, did you want the marquee within a webpage (like just scrolling text object) or did you want to use marquee for QML objects.

                Both are possible using the WebView. You can define QML objects in the WebView as a plugin.
                See this example: http://qt.gitorious.org/qt/kinetic/blobs/43199af242918b3c77bb47bdcc3ec60f8236b0d3/examples/declarative/webview/qml-in-html.qml

                • Sacha
                1 Reply Last reply
                0
                • ? This user is from outside of this forum
                  ? This user is from outside of this forum
                  Guest
                  wrote on 7 Dec 2010, 06:00 last edited by
                  #8

                  [quote author="xsacha" date="1291681522"]Uh, this was definitely closed! I couldn't reply. Don't know why it was closed as I was expecting a reply by OP.

                  [/quote]

                  xsacha maybe the page hadn't loaded fully or the script failed. I've seen it happen sometimes but very rare. a refresh should usually solve this issue

                  1 Reply Last reply
                  0

                  7/8

                  7 Dec 2010, 00:25

                  • Login

                  • Login or register to search.
                  7 out of 8
                  • First post
                    7/8
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved