Results 1 to 4 of 4

Thread: QML Combobox with QStringListModel

  1. #1
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QML Combobox with QStringListModel

    I have a QStringListModel which is configured using the setStringList method.

    I'm trying to use this model in QML Combobox. And I have exposed this model to qml using setContextProperty but I can't find the role name to be used in QML

    I can't find a way to do so.

    Please suggest.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML Combobox with QStringListModel

    "display", the name for Qt::DisplayRole
    See QAbstractItemModel::roleNames() for the default mapping.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    volcano (29th November 2016)

  4. #3
    Join Date
    Jan 2010
    Posts
    95
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QML Combobox with QStringListModel

    Thanks for the suggestion anda_skoa

    Is there any way to disable selection in the combobox? I want to use the combobox to show the first item and not allow click on the item at index 1 or index 2

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML Combobox with QStringListModel

    Not sure. You could try adding a MouseArea to those items and letting it take the events.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 3rd September 2013, 19:47
  2. how do I use comboBox
    By QT++ in forum Newbie
    Replies: 5
    Last Post: 2nd July 2013, 14:13
  3. Replies: 4
    Last Post: 7th March 2013, 16:20
  4. Help ComboBox
    By vinny gracindo in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 19:41
  5. ComboBox of bmp:s
    By SailinShoes in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2008, 15:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.