I have an array of my custom made buttons:
Button buttons[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, doesnt work:
Button help = buttons[1];
buttons[1] = buttons[2];
buttons[2] = help;
Can anybody help me with this?
I have solved using a pointer array:
Button *pntArray[5];
Button *help;
pntArray[0]=&buttons[0];
pntArray[1]=&buttons[1];
help=pntArray[0];
pntArray[0]=pntArray[1];
pntArray[1]=help;
QObjectbase class does not allow the assignment operator or the copy constructor. Unless you have manually created these (which is usually unwise), declare your instances on the heap and use pointers in the array instead.