Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I've made a list displayed on Tab Page, its suppose display a Subtitled List Item: conversation (An item that displays Icon + Text), I've got a button that allows the user to change the text of that List item:

conversation.text : ""

however, whenever I'm using it, Qt displays an error stating that "conversation is not defined" when clearly I have defined it underneath, but for some reason the button is not being able to access or see it, so is there anyway to overcome this?

ListView {
    id: conversationList
    anchors.fill: parent
    model: 1
    delegate:
    ListItem.Subtitled {
        id: conversation
        icon: Qt.resolvedUrl("avatar_contacts_list.png")
    }
}

thankyou :)

share|improve this question

1 Answer 1

First of all: please allways show complete code examples. There is so much guessing involved in answering your question as it is now...

I GUESS that you want to access the items in the listview by there id. In your special case there seems to be only one item (because you wrote model: 1, but in general, there are N elements. Based on your logic, they would all have the same id, because all are based on the same delegate. This however is not possible and the id of the delegate can only be used in the item itself.

Since you only have one item, why do you have the ListView at all? Why not simply use the ListItem.Subtitled itself? Then you can use the id as you indent to use it.

share|improve this answer
    
>> xubuntix, ah I seem to be not describing myself clearly: There is a button under the tool bar, for every time its pressed, a new ListItem.Subtitled is created: conversationList.model = conversationList.model + 1 However for every time the button is pressed, the program is able to change the Text and Subtext of the Listitem.Subtitled (conversation): conversation.text = " " conversation.Subtext = " " the problem is that when the program cannot seem to detect the id "conversation", giving a: conversation not defined error :( –  user140120 Mar 18 '13 at 22:36
    
I mean, I dont need to give so much detail, the main problem is just I can't seem to edit conversation.text from outside the ListView, it keeps giving me: conversation not defined. If i do just take out the ListView and just use ListItem.Subtitled, then I can access conversation.text, but of course i wouldn't be able to make a list of that ListItem. –  user140120 Mar 18 '13 at 22:47
    
@user140120 : so you would have N items all with the id conversation... which one of them should then be changed by conversation.text ? No that is not possible for good reason. You need a different setup with a real model of ListItems –  xubuntix Mar 19 '13 at 11:42
    
>>xubuntix, yea i recently realized that this setup wouldn't work for what I'm aiming for, anyhow thanks :) –  user140120 Mar 19 '13 at 23:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.