Listbox


#1

Hello,

I try to get a simple listbox added to my test project but I get this compiler error all the time:
Compiler Error C2512. ‘identifier’ : no appropriate default constructor available

I’ve started using Jucer with the same problem, then I decided to try it directly but I can’t get rid of this error.
I’ve searched the forum but couldn’t find something helpful.

This is what I did:

Vcommander.h

public:
    //==============================================================================
    VCommanderEditor (AudioProcessor *_VCommander);
    ~VCommanderEditor();

    //==============================================================================
    //[UserMethods]     -- You can add your own custom methods in this section.
    //[/UserMethods]

    void paint (Graphics& g);
    void resized();
    void sliderValueChanged (Slider* sliderThatWasMoved);

    // Binary resources:
    static const char* buttonBkg_off_png;
    static const int buttonBkg_off_pngSize;

    //==============================================================================
    juce_UseDebuggingNewOperator

private:
    //[UserVariables]   -- You can add your own custom variables in this section.
        ListBox* MyListBox;
    //[/UserVariables]

VCommander.cpp


#include "VCommanderEditor.h"


//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]

//==============================================================================
VCommanderEditor::VCommanderEditor (AudioProcessor *_VCommander)
    : AudioProcessorEditor(_VCommander),

    //[UserPreSize]
    //[/UserPreSize]

    setSize (1200, 800);

    //[Constructor] You can add your own custom stuff here..
    addAndMakeVisible (MyListBox = new ListBox (T("Test")));
    MyListBox->setRowHeight (28);
    //[/Constructor]

I’ve skipped all the other code so far to keep this example code tiny.
Can somebody point me to the problem?

Thank you,
Joerg


#2

Sounds like a basic c++ misunderstanding, but it’s not clear from your example code what’s going on.


#3

the ctor for the ListBox is ListBox (const String &componentName, ListBoxModel *const model)
you need to provide the second parameter in the constructor witch is the model (usualy the same class, i almost always pass this, but it’s up to you)


#4

Hello,

Yes Jules, it is definitely a basic C++ misunderstanding because I am leaning by doing. I used to work with PowerBasic8 (which is not object orientated).
I do therefore much appreciate any help and patience!

Thank you atom for your input. It is still not really clear to me because I do not really understand how to create a listbox in jucer.
I have a few basic jucer questions:

Should I see a list box in inside the generic component once I have all parameter set up in a right way or is it still a place holder?
Where do I need to set these parameter in jucer, in the class view or subcomponents view?

This is the way I would go to create a list box in jucer:

1 – Create a new component
2 – Add a new generic control and set size and position
3 - Then I have to set the general class settings and the component setting and this is where I stuck

Would you please be so kind to tell me exactly what to put where?
I just want to have an ordinary list box for the beginning, nothing special.

General class settings
class name: LB_ProgramManager
component name: ProgramManager
parent classes: public ListBox, public ListBoxModel
constructor params: ???
member initialisers: ???

Component settings
member name: ???
name: ???
virtual class: ???
class: ListBox ???
constructor params: ???

I appreciate your help!

Joerg