Main Menu
Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - cl3m

#1
Help requests / Re: ListView removeItem error
03 September 2021, 01:12:39
Problem solved! updateGui() was actually messing things up as you mentioned, because it was reading the selected item text to update other widgets. The issue was simply fixed by testing if getSelectedItemIndex() returns -1 at the beginning of updateGui().

Thanks for your help @texus and @Kvar1z!
#2
Help requests / Re: ListView removeItem error
02 September 2021, 20:03:58
getSelectedItemIndex() returns 0, which is okay because my ListView only  contains 1 item.
I believe that the issue comes from the removeItem() method when encapsulated in a signal:
for instance, with 1 item in the ListView, this piece of code works:
QuotelistView->removeItem(0);

but this one does not and it throws the same error as mentioned earlier:
QuotedeleteBtn->onMousePress([&] {listView->removeItem(0);});
#3
Help requests / ListView removeItem error
02 September 2021, 16:23:14
Hello,

I'm trying to create a button that deletes the selected item in a , but whenever I click on the button, listView->removeItem() throws an std::out_of_range error in memory. Here is my code :

tgui::ListView::Ptr listView = gui.get<tgui::ListView>("list");
    tgui::Button::Ptr deleteBtn = gui.get<tgui::Button>("deleteBtn");

    listView->addColumn("Title",240U);
    listView->addColumn("Deadline", 100U);
    listView->addColumn("Done ?",50U);
    listView->addItem({ "Test", "03/09/2021", "No" });

    listView->onItemSelect(&updateGui,std::ref(gui)); // updates other widgets
    deleteBtn->onMousePress([&] {
        listView->removeItem(listView->getSelectedItemIndex());});
   
    gui.mainLoop();

What am I doing wrong here ?
Thanks