I have an app with a QTabWidget containing 5 tabs. Each tab has 1 QGraphicsView.
The first time i run the application, the fitInView function only works on active QGraphicsView, after I've change to all tabs, the fitInView function keeps working correctly.
It's like i have to use it at least 1 time with each tab active for got it working correctly.
Any idea what could be wrong? Something about fitInView or QGraphicsView that i should to know?
It's a lot of code, i don't know what to copy/paste >_<, this is the code used each time an image is loaded (this is the code of 1 of the 5 QGraphicsView, all are almost the same):


Header File
Qt Code:
  1. QStringList flyerList;
  2. QGraphicsScene FlyerScene;
  3. QTimer flyerTimer;
  4. int FlyerSwapPos;
To copy to clipboard, switch view to plain text mode 

Fragment of cpp file:
Qt Code:
  1. void RetroSuite::MEDIA_Flyer() {
  2. FlyerScene.clear();
  3. flyerList.clear();
  4.  
  5. QSettings inisets(QString("data/systemdata/%1/%2.ini").arg(CurrType).arg(CurrSID), QSettings::IniFormat);
  6. QString folder = inisets.value("Flyer/Folder").toString();
  7.  
  8. if (!folder.isEmpty() && folder.length() > 3) {
  9.  
  10. QDirIterator iter(folder, QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
  11. while (iter.hasNext()) {
  12. QFileInfo nextfile = iter.next();
  13. if ((CurrGameName.contains(nextfile.completeBaseName()) && CurrType != "Arcade") || (nextfile.completeBaseName() == ( CurrLaunchName) && CurrType == "Arcade")) {
  14. flyerList << nextfile.absoluteFilePath();
  15. }
  16. }
  17. if (flyerList.count() > 0) {
  18.  
  19. flyerItem = FlyerScene.addPixmap(QPixmap());
  20. flyerItem->setPixmap(QPixmap(flyerList.at(0)));
  21. ui->flyerView->setFlyerItem(flyerItem);
  22.  
  23. FlyerScene.setSceneRect(QPixmap(flyerList.at(0)).rect());
  24.  
  25. FlyerSwapPos = 0;
  26.  
  27. if (inisets.value("Flyer/Fit").toBool()) {
  28. ui->flyerView->setTransform(QTransform());
  29. ui->flyerView->fitInView(flyerItem, Qt::KeepAspectRatio);
  30. ui->flyerView->show();
  31.  
  32. } else if (inisets.value("Flyer/Scaled").toBool()) {
  33. ui->flyerView->resetTransform();
  34.  
  35. switch( inisets.value("Flyer/SizeScale").toInt() ) {
  36. case 0:
  37. ui->flyerView->scale(0.1, 0.1);
  38. break;
  39. case 1:
  40. ui->flyerView->scale(0.2, 0.2);
  41. break;
  42. case 2:
  43. ui->flyerView->scale(0.3, 0.3);
  44. break;
  45. case 3:
  46. ui->flyerView->scale(0.4, 0.4);
  47. break;
  48. case 4:
  49. ui->flyerView->scale(0.5, 0.5);
  50. break;
  51. case 5:
  52. ui->flyerView->scale(0.6, 0.6);
  53. break;
  54. case 6:
  55. ui->flyerView->scale(0.7, 0.7);
  56. break;
  57. case 7:
  58. ui->flyerView->scale(0.8, 0.8);
  59. break;
  60. case 8:
  61. ui->flyerView->scale(0.9, 0.9);
  62. break;
  63. case 9:
  64. ui->flyerView->scale(1.0, 1.0);
  65. break;
  66.  
  67. }
  68. } else {
  69. ui->flyerView->setTransform(QTransform());
  70. }
  71. }
  72. if (inisets.value("Flyer/SwapAuto").toBool()) {
  73. flyerTimer->start( inisets.value("Flyer/SwapTimer").toInt() * 1000 );
  74. }
  75. }
  76.  
  77.  
  78. }
To copy to clipboard, switch view to plain text mode 

I'm really lost with this, i have no idea what is wrong.