Search code examples
widgetgtkmm

gtkmm is it possible to add same widget to a vbox more than once


Here is my problem. I have this form of information I want to display. I have already made a vbox in another class that contains this information.

The information is about their additional work experience for related to the job they are applying for. Of course they can have multiple work experiences. I want to display all their work experiences in the form they used to input it (which is the vbox in another class).

Is it possible to add this same vbox multiple times to a window (and by this I mean to another vbox on the window, as windows can only contain one widget)?

Thank you in advance!


Solution

  • No, you can't add the same widget twice, every widget on a form needs to be unique one. You may use method (...or factory) for creating new vboxes, to avoid duplication of code.

    The real reason for not having such a possibility: imagine you've added some component to your vbox. Now, you'd like to add the same vbox to this vbox. Wait, what about widget childrens? This vbox would became its own child, overwriting its own child! This is why you have to create every widget as different object.