qt - Swapping Buttons in array -


I have an array of my custom buttons:

  button button [5 ]   

Now I want to swap two elements of this array, for example buttons [1] and buttons [2]. How do I do this? Just stating the following does not work:

  button help = button [1]; Button [1] = button [2]; Button [2] = help;   

Can anyone help me with it?

I have solved using an indicative array:

  button * pntArray [5]; Button * Help; PntArray [0] = & amp; Button [0]; PntArray [1] = & amp; Button [1]; Help = pntArray [0]; PntArray [0] = pntArray [1]; PntArray [1] help =;  

QObject does not allow the base class assignment operator Or copy creator unless you have created it manually (which usually happens), declare your examples on a heap and instead use pointers in the array.

  // If you want, install the button, if you were just making them on the stack // First, a default preliminary should be enough. Although in general // you at least pass the 'self' widget as a parent in the Q, so you do not have to worry about deleting the button. QVector & LT; Button * & gt; Button (5); (Button * button: button) for {// C ++ 11 only! Button = new button (); } // Even when you have to swap two entries: std :: swap (button [1], button [2]);    

Comments