update a ListView when dataModel changes

Hi gang,.

I have a defined GroupDataModel as a Q_PROPERTY a class custom C++.

I join this GroupDataModel a ListView in QML.

Make changes to the items in the GroupDataModel by pulling on the elements in the model in a ListOfObjects.

I can see that the changes are effective for exit qDebug(), but the ListView refresh.

Q_PROPERTY, I have a NOTIFY signal defined (on onItemListChanged), and in the function where I edit items, I emit this signal (emt onItemListChanged(), but the ListView does nothing.)

How can I get the updated list?

Here is the function update the items.

void WorkManager::updateKey(QString newKey, int whichObject) {

    if (!newKey.isNull()) {
        QList  myObjects = m_model->toListOfObjects();
                Task * myTask = (Task *) myObjects[whichObject];
                qDebug() << "object is : " << myObjects[whichObject];
                qDebug() << "object key is: " << myTask->key();
                myTask->setNotifyKey(newKey);
                emit onItemListChanged();
                qDebug() << "modified object key is : " << myTask->notifyKey();
    }

}

do I need to connect a signal to a slot somewhere?  I thought that this will be done automatically.

THX,

J

Ah, I see. I really have to update the model to get this fire its signals.

Add this:

             QVariantList indexPath = m_model->findExact(myTask);
                qDebug() << "WorkManager::updateItem(), indexPath is : " << indexPath;
                m_model->updateItem(indexPath, myTask);

makes work.

Here is the full function:

void WorkManager::updateKey(QString newKey, int whichObject) {

    if (!newKey.isNull()) {
        QList  myObjects = m_model->toListOfObjects();
                Task * myTask = (Task *) myObjects[whichObject];
                qDebug() << "object is : " << myObjects[whichObject];
                qDebug() << "object key is: " << myTask->key();
                myTask->setNotifyKey(newKey);                                QVariantList indexPath = m_model->findExact(myTask);                                qDebug() << "indexPath is : " << indexPath;                                m_model->updateItem(indexPath, myTask);
                qDebug() << "modified object key is : " << myTask->notifyKey();
    }

}

Tags: BlackBerry Developers

Similar Questions

  • Update a listView when a page is skipped

    Hi all

    I'm new in the cascades, in the developing world. I'm trying to do a two pages about the first page exposure items to a listview and has buttom "new item" action at the bottom. it triggers now pushes the second page that contains fields for a new record. He has a backup action button. When trigged inserts the element in the database and revealing the first page is displayed. My problem is that the new record is not displayed on the page. at least I got close and reopen the application. I use a sql database to populate the list. and I do everything in the cascades (no C++ backend)

    Thanks in advance for your help.

    Welcome on the support forums.

    you have several options.

    -Insert the item in sql, then reload the entire listview. You can do it by listening to the signal onTopChanged of the navigation pane.

    -inclusion of the item in the list or the model data (as well as in sql). It's a better solution in most cases, at least if the sorting is not done by sql or similar.

  • When I change albums on my site of Porta Firefox does not update the site well as do other browsers.

    I have a site of Porta by using 'bystander' and when I update the albums he is generally very good, but today I changed the content in 2 albums and even if they are updates on other browsers, the changes are not displayed in my Firefox. I deleted history etc in the case that was originally a delay in updating the browser, but it made no difference. Anyone has any ideas please?

    This has happened

    Just once or twice

    == I changed the content of my Web site.

    Try to clear the browser cache.
    Tools > Options-> advanced > > tab network - storage offline = clear now button.

  • Error: Failed to setup of the Windows updates. Restoration of the changes. Do not turn off your computer when you try to install Windows updates

    I got an error message in step 2 of configuring updates - "updates were not correctly configured.  Returning from changes' anyone can help solve this problem?

    Error: Failed to setup of the Windows updates. Restoration of the changes. Do not turn off your computer when you try to install Windows updates
    http://support.Microsoft.com/kb/949358

  • Windows security for the family and parental controls not update/refresh when you change curfews, no matter what I do

    I have windows 8 and 7, two different computers. When I change a curfew on the WFS Web site, our computers do not receive the update and do not allow access monitored accounts. On the 7 machine, I go to Windows Live Family Safety Filter, hit the icon refresh at the top right and a popup says I already have the last parameters, or FS settings have been updated. but in no case can the user log on. When the monitored user tries to connect, a message says "your account has time restrictions... ».  What's wrong???

    Here are the parameters:

    Hi Peter,.

    Welcome to the Microsoft Community forums.

     
    I understand when you do the curfew change on the site Web WFS, computers
    do not get the update and not allow access to the monitored accounts as you have
    two computer windows 7 and 8.

    Please follow the response of the Rudi on July 13, 2012.

    You can also go through the link on the safety of the family
     
    Keep us updated on the results.
  • I'm on Windows 10. A works fine until the update. How can I make Adobe Acrobat Reader (free verision) my default DC? Seems that the default value is E pdf and when I change the default in the flashes of screen reader and forms are in the same format. I ha

    I'm on Windows 10. A works fine until the update. How can I make Adobe Acrobat Reader (free verision) my default DC? Seems that the default value is E pdf and when I change the default in the flashes of screen reader and forms are in the same format. I rather Acrobat format if possible. Thank you

    Hello

    Could a right click on the PDF file > open with > choose program by default and select CD player as default PDF Viewer.

    You can do it from the control panel as well.

    This would make CD player as default PDF Viewer.

    Concerning

    Sukrit diallo

  • How to update the table when change list item in the classic report

    Hello
    I worked with apex 4.2 and I create normal classic report with list (named loved) select a column, now I want to update the table when the user changes the list with the new value, I can't create a dynamic action to do this, I create checkbox with the primary key and the loop for check point to update the table but I can not get the value of the list item. and for more speed, the user want to do it when changing the value from the list.

    My question
    1. how to do it in javascript and get the value of the list item and update the table with the new value
    2. do I have to use the API to create the list item so I can get the value of the report item or what.





    Thank you

    Ahmed

    You can find a lot of information in this forum (and outside in google) when you search for AJAX processes and demand. However, the tutorial in the link below should be useful:
    http://www.Oracle.com/WebFolder/technetwork/tutorials/OBE/DB/hol08/apexweb20/ajax_otn.htm

    BTW, if we answer your question, don't forget to mark the appropriate post as correct. It will help all of us in the forum.

  • Small update on screen when changing pages

    Hi all, we note a few pixels change on the display of the pages when I change pages in the menu (it is easier to see on the big screen). The entire page moves from left to right or from right to left. Of course, I use the same master page to all pages. You can see the construction site in this address: home . Anyone know why and how fix it? Thank you

    It's the vertical scroll bar that doesn't appear on pages with more content than a single screen.

    In page properties, you can change the visibility of the scroll bar for "always on".

    (Sorry, I don't know the term exact English.) Maybe the screenshot for help.)

    Fenja

  • ToolTips don't update when I change

    Hello

    Whenever I update my tooltips (i.e. changes to the text, properties), I try to view them in a browser. But for some reason, they don't update in the browser window. They still have the same text and properties as before... can someone explain this?

    Hello

    Have you tried to clear the cache of your browser and refresh the page?

    PZ

  • Update of ListView dummy image using images from URL http

    Hi guys...

    Please help me with this.

    I have created a ListView in QML file and filled with data received from a webservice. Since this web service provides all the images, I have to place a dummy image at this location. Then I used another method to retrieve images of the url. Now, I got the image in my CPC file. But I could not update my listview. I tried several methods. But failed.

    Here is my code snippet.

     ListView {
                    id: listView
                    objectName: "listView"
    
                    dataModel: ArrayDataModel {
                        id: myListModel
    
                    }
    
                    // Override default GroupDataModel::itemType() behaviour, which is to return item type "header"
                    listItemComponents: ListItemComponent {
                        id: listcomponent
                        // StandardListItem is a convivience component for lists with default cascades look and feel
                        StandardListItem {
                            title: ListItemData.postText
                            description: ListItemData.postDate
                            status: ListItemData.filePath
                            imageSource: "asset:///images/4.png"
                        }
    
                    }
                    layoutProperties: StackLayoutProperties {
                        spaceQuota: 1.0
                    }
                    horizontalAlignment: HorizontalAlignment.Fill
                    verticalAlignment: VerticalAlignment.Fill
    
                }
    

    In the PRC, I get my image like this.

    void PostHttp::imageFetcher(){
    const QUrl url("http:///828/828_20135312012288.png");
    if (flag1 == true) {
        get(url);
    }
    }
    void PostHttp::onImageReply(){
        QNetworkReply* reply = qobject_cast(sender());
        QString response;
        QImage img;
        QString filePathWithName = "data/img/";
        QString imageName;
    
        if (reply) {
                if (reply->error() == QNetworkReply::NoError) {
                    flag1 = false;
                    const int available = reply->bytesAvailable();
                    if (available > 0) {
                    const QByteArray buffer(reply->readAll());
                    response = QString::fromUtf8(buffer);
                    img.loadFromData(buffer);
                    img = img.scaled(40, 40, Qt::KeepAspectRatioByExpanding);
                    const QImage swappedImage = img.rgbSwapped();
                    const bb::ImageData imageData = bb::ImageData::fromPixels(
                            swappedImage.bits(), bb::PixelFormat::RGBX,
                            swappedImage.width(), swappedImage.height(),
                            swappedImage.bytesPerLine());
                    bb::utility::ImageConverter::encode(QUrl(QDir::currentPath() + "/shared/camera/img.png"), imageData, 75);
                    qDebug()<<"current path is "<
    

    Thanks in advance

    You can pass a QByteArray of image data coded directly to an imageView in the image property, set of QVariant::fromValue (). However, in your case you can place the uri to which you saved the image and not the bytes. Advantage: cascades puts these images in cache. If you use deterministic file names, you can avoid any networking calls or loading of images when only the populated list of point sier after be recycled.

    img.loadFromData(buffer);
    img = img.scaled(40, 40, Qt::KeepAspectRatioByExpanding);
    img.save(QDir::currentPath() + "/shared/camera/img.png"), 0, 75);
    

    QImage can do all this for you, without permutation of bytes.

    All you have to do is then updated the datamodel.

  • Refresh JComboBox in one class when a changes JList in another class?

    Hello
    I have a small program where I am trying to update a JComboxBox in my class Main.java (a JFrame) when the contents of a JList change in another class JFrame, ProjectManager.java

    I have three classes involved in the present.

    Main
    Poster of the JComboBox

    ProjectManager
    Displays the JList and here you can add/remove items in the JList
    When this happens I want changes to be reflected in the main class

    ProfileManager
    The above two classes get their datamodel of this class by calling the static methods:
    public static ListModel getProfileListModel()
    and
    public static ComboBoxModel getProfileComboboxModel()
    I'm new to Java/Swing and I guess I'm must write a ListDataListener who warns 'Hand' that JList has changed.
    Who update the JComboBox.

    The problem is how to do that when I have three classes involved?

    I tried to create this listener in the main class:
     class ProfileListDataListener implements ListDataListener {
    
            public void contentsChanged(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalAdded(ListDataEvent e) {
                getProfiles();
            }
    
            public void intervalRemoved(ListDataEvent e) {
                getProfiles();
            }
            
        }
    getProfiles() looks like this:
    private void getProfiles() {
    cmbProfiles.setModel(profileManager.getProfileComboboxModel());
    }
    I can't add this listener to the ListDataModel since my class of earphone is not static, and if I do static, I can't call the method not static getProfiles().

    Anyway, my question is, what is the right way to do it when I want to notify a listener in the main class of class ProjectManager?

    Thank you.

    There are several ways (and I hope at least one is correct)
    You tell us how you want to update the drop-down list.
    I guess it must reflect the content of the JList. Yet,.
    I will describe the General.

    1)
    -you create hand declaring the combo as a global variable
    -you create ProjectManager by passing a reference to hand
    -join a listener JList of ProjectManager
    When the listener fires, you have access to the drop-down list via the reference of hand and the update.

    1A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In this case ProfileManager should have the
    the reference to hand. -By the way: you have several instances of hand or ProjectManager?
    I do not see the need for static methods in ProfileManager yet.

    2)
    -you create hand
    -you create an instance of the ProjectManager and ProjectManager must declare his
    JList as a global variable
    -You can access this list via the instance of ProjectManager
    -join a listener this list in hand and update the drop when the
    lights of the listener.

    2A)
    Rather than attach the listener to the JList, you can attach it to its model,
    that might be in ProfileManager. In the main case must have a reference to
    ProfileManager.

    I personally prefer to have the Jlist and its auditor in the same class.
    And if my assumption is right that the combo should reflect the content of the JList,
    There is no need of the ProfileManager class if his job is only to define models of
    the JList and the JCombobox.

  • I have a desktop computer and a laptop. When I change a bookmark on one, it does not change on the other, even if I am connected to sync

    I have a desktop computer and a laptop.
    When I change a bookmark on one, it does not change the other even though I am connected to the sync.

    Sync is meant to do?

    Most probably one of the two computers has corrupted data which does not allow the sync complete.

    Refresh (called "Reset" in older versions of Firefox) can solve a lot of problems in restaurant Firefox as his default factory while saving your bookmarks, history, passwords, cookies, and other essential information.

    Note: When you use this feature, you will lose all the extensions, toolbar customizations, and certain preferences. See article Firefox Refresh - reset modules and parameters for more information.

    Refresh for Firefox:

    1. Open the troubleshooting information page using one of the following methods:

      • Click the menu button

        click Help

        and select troubleshooting information. Should open a new tab containing your troubleshooting information.

      • If you are unable to access the Help menu, type Subject: support in your address bar to bring up the troubleshooting information page.
    2. At the top right of the page, you should see a button that says 'Refresh Firefox' ('reset Firefox' in older versions of Firefox). Click on it.
    3. Firefox closes. Once the update process is complete, Firefox will display a window with the imported information.
    4. Click Finish and reopen Firefox.

    This corrects the problem? Please report to us!

    Thank you.

  • When I change the battery on a power outlet, Firefox is empty, I close firefox, the "do you want to close" box is empty, too.

    I can't change current alternative to battery without incident. When I change the battery on a power outlet, Firefox blinks several times then turns off. To close the browser, I click on the 'X', which fortunately remains, and that the box "you want to close" is empty also. I hit enter and Firefox closes. I reopen and select restore previous... and I can continue. Just something I've ever known, do not know how to fix it. Sometimes, if I reduce the browser (""-"") at the top right before plugging in my diet, I can work around this problem. Sometimes he waits until I have maximize the browser, and again, it flashes and turns off anyway.

    Hello numberonejason, this is perhaps a problem with hardware acceleration. try updating your graphic driver, or in the case where this does not resolve the problem, disable hardware acceleration in firefox > options > advanced > General.

  • Default configuration of the Windows updates. Restoration of the changes. Do not turn off your computer

    Hi, I just refreshed my laptop that I got a few drops FPS at random. Initially, it worked fine, but after a while before instaled Norton started to cause me problems. At this time I uninstalled it and when he asked me to computer restatr now, I did. Now I'm stuck with this message window loading. Restart the computer from time to time, but the message is always the same: failure of configuration of Windows updates. Restoration of the changes. Do not turn off your computer.
    Computer: hp pavilion n006sm
    Operating system: win 8 pre-installed
    At the moment I'm stuck on this window for over an hour and nothing has changed

    Seems that problem solved by itself. As I correctly uninstalled Norton, I just put my automatic updates and restarted my laptop again. He installed the updates with no problem and its working fine. Seems that Norton was really the problem, will keep you informed.

  • Satellite L650 - IP address invalid when I change of place of connection

    Well, my problem is: in my house, we have several points of LAN connection, like, bedrooms, living rooms and so on. But the thing is when I change the connection point with my laptop (like going from living room to bedroom), LAN stop working! I can't reach the internet or the network itself.

    What can I do? There is no configuration that I should change? I had this problem once, with jobs and what I did was to "change" the MAC address of the network card.

    So, what can I do?

    Hi when,.

    May I ask why you n t use a WLAN connection if you often change rooms? I think that s more at ease because the cable network is always a bit boring if I often change rooms.

    In any case, what happens if you unplug the LAN cable and connect another cable in another room? The laptop recognizes the cable or not?

    In my opinion, you need to update the network driver and check your TCP/IP configuration at home.
    MAC address can never be changed because it s a hardware based address.

Maybe you are looking for