Advertisement
Max13

Qt Showing nothing

Jul 2nd, 2011
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. void MainWindow::dropEvent(QDropEvent * event)
  2. {
  3.     event->acceptProposedAction();
  4.  
  5.     const QMimeData * mimeData = event->mimeData();
  6.  
  7.     // check for our needed mime type, here a file or a list of files
  8.     if (mimeData->hasUrls())
  9.     {
  10.         QList<QUrl> urlList(mimeData->urls());
  11.         QString fileName;
  12.         bool encrypted;
  13.  
  14.         // extract the local paths of the files
  15.         for (int i = 0; i < urlList.size() && i < 32; ++i)
  16.         {
  17.             fileName = urlList.at(i).toLocalFile();
  18.  
  19.             // Initialisation de la fenêtre de chargement
  20.             this->tmpWin = new QWidget;
  21.             QVBoxLayout * vLayout = new QVBoxLayout;
  22.             QLabel * txtLabel = new QLabel(tr("Processing..."));
  23.             QProgressBar * pBar = new QProgressBar;
  24.  
  25.             pBar->setRange(0, 0);
  26.             vLayout->addWidget(txtLabel, 0, Qt::AlignHCenter);
  27.             vLayout->addWidget(pBar, 0, Qt::AlignHCenter);
  28.  
  29.             //this->tmpWin->setAttribute(Qt::WA_DeleteOnClose);
  30.             this->tmpWin->setLayout(vLayout);
  31.             this->tmpWin->setWindowFlags(Qt::SplashScreen);
  32.             // ---
  33.  
  34.             if ( fileName.contains(QRegExp(APPCRYPTEXT+"$")) )
  35.             {
  36.                 this->tmpWin->show();
  37.                 qApp->processEvents();    // I tried this line
  38.                 this->tmpWin->update(); // and/or this line
  39.                 this->db->decryptFile(fileName);
  40.                 this->tmpWin->hide();
  41.             }
  42.             else
  43.             {
  44.                 this->tmpWin->show();
  45.                 qApp->processEvents();    // I tried this line
  46.                 this->tmpWin->update(); // and/or this line
  47.                 this->db->encryptFile(fileName);
  48.                 this->tmpWin->hide();
  49.             }
  50.         }
  51.  
  52.         this->tray->showMessage(tr("Finished !"), tr("I've finished encrypting or decrypting (whatever it was)\nyour files..."), QSystemTrayIcon::Information, 2000);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement