Question

I'm currently working on a C++ wxWidgets-based software designed to show some data extracted from .txt files. Since I want to create multiple tabs, I decided to use wxAuinotebook with wxListCtrl.

To create a new tab in wxAuiNotebook, I need an object and I want this object to be a wxListCtrl. My goal at the moment is: every time I load a file, the software extracts some data and creates a new tab in the wxAuinotebook. And to do that, I create a new object in a dynamic array (vector) to have a new ListCtrl object as a base for the new tab every time.

Here are the interesting parts of my code:

std::vector<wxListCtrl> *Listes;
int nbr_listes = 0; // with a variable to store how many ListCtrl I create

I declare a vector to contain every ListCtrl objects. And, after the file loading, I create a new ListCtrl object in the vector:

Listes->push_back((new wxListCtrl(AuiNotebook1, ID_LISTCTRL1, wxPoint(121,48),
                                  wxDefaultSize, 
                                  wxLC_LIST|wxTAB_TRAVERSAL|wxVSCROLL,
                                  wxDefaultValidator, _T("ID_LISTCTRL1"))));
// And I want to add a page to the auiNotebook
if (!AuiNotebook1->AddPage(&Listes->at(nbr_listes), 
                           OpenDialog->GetFilename(), 
                           true,
                           wxNullBitmap)) //ajout d'une page passée en focus
    {
        cout << "Echec de l'ajout de page! \n";
    }

But the compiler returns an error in listCtrl.h:

\include\wx\msw\listctrl.h|446|error: 'wxListCtrl::wxListCtrl(const wxListCtrl&)' is private

How can I properly add a page to the auiNotebook with a ListCtrl inside? I tried some different ways like declaring the vector as a vector of pointers, but that failed, too.

Thank you for reading.

Was it helpful?

Solution

it is probably a small typo but it doesn't work because of this:

std::vector<wxListCtrl> *Listes;

you probably ment to do

std::vector<wxListCtrl*> Listes;

EDIT: That is because everytime you try to add a wxListCtrl to your vector as a variable allocated on the stack and not on the heap it has to call the copy constructor (which is declared private) and thus it generates your error.

In addition (depending on your wxWidgets version) I would suggest to display your data with wxDataviewCtrl

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top