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. [Moved] ListView inside ComboBox wont populate...PLz help
Forum Updated to NodeBB v4.3 + New Features

[Moved] ListView inside ComboBox wont populate...PLz help

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 3 Posters 4.6k 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
    andresteves
    wrote on last edited by
    #1

    Hi all, im a newbie at Qt/QML and Symbian. Sorry for my english.

    I have a situation and i am starting to get desperate without knowing what to do.
    I got the QML ComboBox from "Qt Components":https://qt.gitorious.org/qt-components/qt-components/blobs/f97eb3eb5d6e9de3bfca69d291ffc1564aee8a01/ComboBox.qml

    My situation is that i want to populate the QML ComboBox with elements from C++ (a QStringList). Next i will present the errors and the code where i am trying to populate the ComboBox. Just a heads up: the ComboBox has a ListView where the items are inserted.

    Errors:
    @file:///C:/Users/andre.esteves/Launcher-build-simulator/qml/Launcher/styles/default/ComboBoxStyle.qml:108: Unable to assign [undefined] to QString text
    file:///C:/Users/andre.esteves/Launcher-build-simulator/qml/Launcher/styles/default/ComboBoxStyle.qml:92: TypeError: Result of expression 'model.get' [undefined] is not a function.@

    C++ Code:
    @
    QStringList appName; //Im filling this in the real code, so no worries
    QDeclarativeView view;
    QDeclarativeContext *ctxt = view.rootContext();
    ctxt->setContextProperty ("apps", appName);
    view.setSource(QUrl::fromLocalFile("example.qml");
    view.show();
    @
    view.show() isnt for display the example.qml file? Im trying to move from one QML file to another with this show() function.

    Part of the QML Code:
    @
    Item {
    Column {
    x: 33
    y: 193
    width: 251
    height: 40
    spacing: 10

      ComboBox{
          id: appbox
          model:myModel
    
          ListView{
              id:myModel
              model:apps
          }
      }
    

    }
    }
    @

    If u need more details, ill be happy to provide.
    Thanks for any help,
    Estevex

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dialingo
      wrote on last edited by
      #2

      I do not understand why there is a ListView inside the ComboBox.
      Are you able to show your QStringList items in ListView alone, or in ComboBox alone?
      If not, you may simply copy from the QStringList example:
      http://doc.qt.nokia.com/4.7-snapshot/declarative-modelviews-stringlistmodel.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thisisbhaskar
        wrote on last edited by
        #3

        [quote author="andresteves" date="1309796620"]

        Part of the QML Code:
        @
        Item {
        ..............
        ComboBox{
        id: appbox
        model:myModel

              ListView{
                  id:myModel
                  model:apps
              }
          }
        

        }
        }
        @
        [/quote]

        Briefly went through ComboBox code. You don't need to have ListView in your code. Its already defined inside ComboBox.

        try below code

        @Item {
        ..............
        ComboBox{
        id: appbox
        model:myModel
        }
        }
        }
        @

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andresteves
          wrote on last edited by
          #4

          Hi thx for the hint Vijay. Trying that.

          For my other question:
          I want to show a different qml file with view.show(). The thing is that i am inside a qml file and want to jump to another qml file. the show() function would do that?

          Thanks for the help

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thisisbhaskar
            wrote on last edited by
            #5

            [quote author="andresteves" date="1310031538"]Hi thx for the hint Vijay. Trying that.

            For my other question:
            I want to show a different qml file with view.show(). The thing is that i am inside a qml file and want to jump to another qml file. the show() function would do that?

            Thanks for the help[/quote]

            Are you coding for Symbian platform?? If so you should try ApplicationWindow, PageStack, and Page. You can easily do what you asked for with those elements.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andresteves
              wrote on last edited by
              #6

              Im coding for Symbian but on Qt 4.7. Goig to check if i can use those libraries on Qt 4.7 .

              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