Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt/C++ (and whatever else you tell me I need) to create a variable number of objects.
Forum Updated to NodeBB v4.3 + New Features

Qt/C++ (and whatever else you tell me I need) to create a variable number of objects.

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 1.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.
  • A Offline
    A Offline
    Anze
    wrote on last edited by
    #1

    Hello everyone! I'm new to Qt but I've spent years programming with Python, php and designing Web user interfaces with CSS.

    I'm learning Qt/C++ to develop a new application for Ubuntu Touch using ubuntu components. I'd like to know how I could possibly generate a number of objects which isn't predefined in the editor but which depends on a variable which is set during the program flow.

    To explain me better I'll give a pair of examples:

    Let main.qml be our main design script in which we have a MainWindow with a set dimension. Inside the MainWindow we have a Flickable which is just a "scrollable" area.

    Now we have a folder containing an unknown X number of pictures. We want to open the folder, find the number and the QURLs to the picture, and for each of them "push" a QML QObject into the .qml file which in this case is actually an object which is decleared by a library in the Ubuntu.Components 0.1 (e.g. UbuntuShape) so that we can display all the images (a kind of picture gallery)

    The best way would be if C++ could actually inject QML code into the .qml file, but this sounds crazy and quite impossible...

    Another example is when we have a list of 'strings' which is retrieved using an http reqest (e.g rss feeds) and we want to "push" in the qml an object list which has all the 'strings' in it.

    Thanks a lot, any help is very appreciated!

    Anze

    P.S:
    Can I let a parent vertical.contentSize attribute (which is an integer) be set by the distance between the first and the last child element? (so that all the elements can be see going "down" in the window) Or do you have better ideas?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shrikantd
      wrote on last edited by
      #2

      Qt.createQmlObject() might be of use to create dynamic objects

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anze
        wrote on last edited by
        #3

        that's awesome! :) thanks! It's a good start... with some arrays, loops, system control.. it's done

        I just need to know one more thing...
        If I create a program which interacts with the system (e.g.: get files in a folder) and install it on a mobile device, does it still work? :)

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shrikantd
          wrote on last edited by
          #4
          1. One way to do it is, ensure the files are stored in a path relative to the folder where application is stored and use API QCoreApplication::applicationDirPath () to refer to the path where app is stored and access the contents relative to it.

          2. Alternatively, you can configure your .pro file to specify additional steps to copy files that are needed by application
            http://qt-project.org/doc/qtcreator-2.5/creator-deployment-maemo.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