dimanche 1 mars 2015

Swap Qt Widgets


I am running into a problem. I want to swap two Qt widgets:



void swap(QMainWindow **w1, QMainWindow **w2)
{
QMainWindow *w3;

w3 = *w1;
*w1 = *w2;
*w2 = w3;
}


However if I have widget1 of type MainWindow1* and widget2 of type MainWindow2* and I call swap(&widget1, &widget2); I get



/home/user/Test/manager.cpp:24: error: invalid conversion from 'MainWindow1**' to 'QMainWindow**' [-fpermissive]
swap(&widget1, &widget2);
^


I must note that MainWindow1 and MainWindow2 are two QMainWindow derived classes.


My question is: Is it possible to function a class that swaps at runtime two polymorphic objects? How can I get around this issue?


Thanks a lot!




Aucun commentaire:

Enregistrer un commentaire