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. QML String List
Forum Updated to NodeBB v4.3 + New Features

QML String List

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 657 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.
  • G Offline
    G Offline
    Gunkut
    wrote on last edited by
    #1

    I need to implement an imaegViever, there will be like 100 images and with next and previous buttons the image that is on the display changes. I thought some ways to do it but they don't look possible with QML:

    1. Having an integer counter that holds the current chosen image index value and then by using something like this:
    image.source=Qt.binding("Images/userGuide" + QString::number(counter);)
    

    However it seems like in QML integer cannot be converted to string.

    1. Using an array of strings that holds the sources of all images. And then comparing the index with counter, using the string value at that index:
    image.source= ImageList[counter];
    

    But, QML lists doesn't support basic types such as strings.. So that way also did not work.
    Then the only option that is left for me is to use switch case but I really don't want to go with that way. What kind of path should I follow for this issue?

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      @Gunkut said in QML String List:

      QString::number(counter)

      String(counter)
      

      https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String

      C++ is a perfectly valid school of magic.

      fcarneyF 1 Reply Last reply
      0
      • fcarneyF fcarney

        @Gunkut said in QML String List:

        QString::number(counter)

        String(counter)
        

        https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String

        fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        @fcarney
        Also:

        "%1".arg(counter)
        

        String literals in QML have .arg functions similar to QStrings in C++.

        C++ is a perfectly valid school of magic.

        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