"No matching function for call to 'ListBox'"


Hi, All.

“No matching function for call to ‘ListBox’”.

I met this error when run this ImGui code.

// ofApp.h
vector<std::string> scores;
		int indexScore;

// ofApp.cpp setup()
for (int i = 0; i < 100; i++) {
	scores.emplace_back("Score - " + ofToString(i));

// draw()
	ImGui::ListBox("##scores", &indexScore, scores); // ## no label

What’s wrong to me ??




Thanks in advance.


you can check the /openFrameworks/addons/ofxImGui/example-demo/ example:

void ofApp::draw(){
//required to call this at beginning

        //ofxImGui::VectorListBox allows for the use of a vector<string> as a data source
        static int currentListBoxIndex = 0;
        if(ofxImGui::VectorListBox("VectorListBox", &currentListBoxIndex, fileNames))
            ofLog() << " VectorListBox FILE PATH: "  << files[currentListBoxIndex].getAbsolutePath();
        //ofxImGui::VectorCombo allows for the use of a vector<string> as a data source
        static int currentFileIndex = 0;
        if(ofxImGui::VectorCombo("VectorCombo", &currentFileIndex, fileNames))
            ofLog() << "VectorCombo FILE PATH: "  << files[currentFileIndex].getAbsolutePath();

//required to call this at end


is not always the same ImGui:: than ofxImGui::, check the examples carefully.

You can compile the example and check the ImGui demo. Look to ShowDemoWindow method definition while running the example to check how it looks to copy paste from it to your project:
in ofApp: … ImGui::ShowDemoWindow(&show_test_window);
–> /openFrameworks/addons/ofxImGui/libs/imgui/src/imgui_demo.cpp

1 Like

if you don’t use the ofxImGui helper, and you require ImGui directly, sometimes I had to use char arrays instead of string vectors to avoid errors:
This is an example to get text from an text input string.
In this below code you can see how to convert from string to char array and backwards.

string textInput_temp = PRESET_name;

        // load char array tab2 from textInput_temp string
        char tab2[32];
        strncpy(tab2, textInput_temp.c_str(), sizeof(tab2));
        tab2[sizeof(tab2) - 1] = 0;
        // loaded string into char array

        if (ImGui::InputText("", tab2, IM_ARRAYSIZE(tab2))) {
            cout << "InputText:" << ofToString(tab2) << endl;

            // put the user typed char array to the string
            textInput_temp = ofToString(tab2);
            cout << "textInput_temp:" << textInput_temp << endl;
1 Like