Project

General

Profile

Turn small WCartesianChart to large popup -> std::move? or

Added by Mark Travis over 1 year ago

I've got a group of small WCartesianCharts that are about 300x200 pixels. I want to allow the user to click on one and have a big version of the chart pop up in a WDialog so that they can see more detail.

The WContainer object creates a unique_ptr to each object and stores the address (from obj.get()) in a std::vector.

Each WCartesianChart creates a signal when ->clicked() that the WContainer object listens for.

Now the question is...

Do I create the WDialog from the WContainer and do a std::move of the WCartesianChart from the WContainer to the WDialog and resize it? Or is there a better technique to do this?

And I guess I'd need to do a std::move of the object back to the WContainer after dismissing the WDialog.

Any hints or tips appreciated!


Replies (2)

RE: Turn small WCartesianChart to large popup -> std::move? or - Added by Roel Standaert over 1 year ago

If you don't want to make another copy of the chart, then the simplest thing would indeed be to move the ownership of the chart to the dialog and then move it back when the dialog is dismissed.

Moving and then resizing the chart will trigger a rerender of the entire chart, though, so it will only be marginally more efficient than just creating a new chart.

RE: Turn small WCartesianChart to large popup -> std::move? or - Added by Mark Travis over 1 year ago

I want the chart to retain changes made by the user, so moving ownership is the best. Thanks!

    (1-2/2)