Vida Marcell Posted December 7, 2021 Share Posted December 7, 2021 Another day another question that i will solve 10 minutes after asking this. Hi everyone! im having a problem, i want to load an image from my disc that has the same name as one of the listbox item, here is what im thinking about: auto pixmap = LoadPixmap("the selected item from the listbox"->GetText()); if (pixmap) { profilepic->SetPixmap(pixmap, PIXMAP_CONTAIN); loadimage->SetText(StripDir("the selected item from the listbox"->GetText())); } here is what i was thinking for solution: auto pixmap = LoadPixmap(partners->Selection->GetText()); if (pixmap) { profilepic->SetPixmap(pixmap, PIXMAP_CONTAIN); loadimage->SetText(StripDir(partners->Selection->GetText())); } summary: i have to get the text from the selected item in a listbox Thanks a lot for the help! Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2021 Share Posted December 7, 2021 To get the text of a widget item it will be something like this: auto s = widget->items[n].text Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 7, 2021 Author Share Posted December 7, 2021 Just now, Josh said: To get the text of a widget item it will be something like this: auto s = widget->items[n].text Okay Josh, thanks! i will try to get it running! Quote Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 7, 2021 Author Share Posted December 7, 2021 32 minutes ago, Josh said: To get the text of a widget item it will be something like this: auto s = widget->items[n].text Allright, so im not familiar with arrays. but should it look like this? auto pixmap = LoadPixmap(partners->items[n].text + ".png"); if (pixmap) { profilepic->SetPixmap(pixmap, PIXMAP_CONTAIN); loadimage->SetText(StripDir(partners->items[n].text + ".png")); } Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2021 Share Posted December 7, 2021 Looks correct. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 7, 2021 Author Share Posted December 7, 2021 Just now, Josh said: Looks correct. the n value is not correct for me, what should i do? Quote Link to comment Share on other sites More sharing options...
Josh Posted December 7, 2021 Share Posted December 7, 2021 Well, which item do you want? The selected item? n = widget->GetSelectedItem(); If this is happening in response to an event, then n would be equal to the event data value. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Vida Marcell Posted December 7, 2021 Author Share Posted December 7, 2021 12 minutes ago, Josh said: Well, which item do you want? The selected item? n = widget->GetSelectedItem(); If this is happening in response to an event, then n would be equal to the event data value. Correct the selected item. now it seems the code is allright, Thanks Josh! Edit: now its totally allright! 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.