Results 1 to 5 of 5

Thread: costumize progress dialog

  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default costumize progress dialog

    i want to create a simple animation when my tableview is updating. I managed to create a scene in a separate dialog, the problem is it doesnt get painted until the tableview gets repainted(when the updating is done), i try to use the QProgress Dialog class but didnt have much success, how do i get this dialog to repaint on a separate thread ?

    thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: costumize progress dialog

    how do i get this dialog to repaint on a separate thread ?
    You don't, at least not with Qt which requires painting to be done from the main thread.

    Since you have not bothered to show any of your code we can only guess that you are blocking the program from reaching the Qt event loop.

  3. #3
    Join Date
    Jan 2012
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: costumize progress dialog

    code is a little messy so i'll try to make it as clear as possible

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6. model = new QStandardItemModel(3000,15,this);
    7. //then add all the items from a file to the model
    8. tableView = new FreezeTableWidget(model);
    9.  
    10.  
    11. ui->centralWidget->setLayout(boxLayout);
    12. ui->centralWidget->layout()->addWidget(tableView);
    13.  
    14. connect(model,SIGNAL(dataChanged(QModelIndex,QModelIndex)),this,SLOT(updateSearch()));
    15.  
    16. void MainWindow::updateSearch()
    17. {
    18. myprogressDialog *progress = new myprogressDialog;
    19. progress->setMinimum(0);
    20. progress->setMaximum(100);
    21. //progress->setValue(50);
    22. progress->show();
    23.  
    24. //hide all the row that do not contain the search word
    25. for (int i=1;i<3000;i++)
    26. if(tableView->isRowHidden(i))tableView->showRow(i);
    27.  
    28.  
    29. QList<int> searchInUse;
    30. for (int i=0;i<14;i++)
    31. {
    32. if (!model->index(0,i).data().toString().isEmpty())
    33. {
    34.  
    35. searchInUse.append(i);
    36. }
    37. }
    38. progress->hide();
    39.  
    40. //myprogressDialog.cpp which is mainly a rotation form
    41.  
    42. scene = new QGraphicsScene(this);
    43. graph = new QGraphicsView(this);
    44. graph->setFrameStyle(0);
    45. graph->setScene(scene);
    46. scene->setSceneRect(-100,-100,200,200);
    47.  
    48. waitD = new waitDisplay();
    49.  
    50. timer = new QTimer(this);
    51. scene->addItem(waitD);
    52. connect(timer, SIGNAL(timeout()), scene,SLOT(update()));
    53. timer->start(20);
    To copy to clipboard, switch view to plain text mode 

    then again the myprogressDialog does not get painted until the tableview is updated
    Last edited by wysota; 11th May 2012 at 23:32. Reason: missing [code] tags

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: costumize progress dialog

    For the duration of the loop at line 25 the program is not processing Qt events. This means that timers (in particular) and many other things will not function. You should have a read of [WIKI]Keeping the GUI Responsive[/WIKI] for some ways to approach this.

  5. #5
    Join Date
    Nov 2006
    Location
    indonesia
    Posts
    55
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: costumize progress dialog

    Hi,
    I get some of tutorial and sample code how to create a progressbar with thread at here :
    http://hopf.chem.brandeis.edu/yangli...ing/index.html
    maybe you can use this.
    Regards,

    Myta

Similar Threads

  1. Resize dialog as progress bar
    By migel in forum Newbie
    Replies: 3
    Last Post: 27th June 2011, 15:23
  2. closing child dialog closes parent dialog
    By sparticus_37 in forum Newbie
    Replies: 2
    Last Post: 28th May 2010, 19:46
  3. Progress Bar Dialog using threads
    By dove17 in forum Newbie
    Replies: 3
    Last Post: 9th April 2010, 16:46
  4. Replies: 4
    Last Post: 11th March 2008, 11:44
  5. progress DIalog
    By mickey in forum Newbie
    Replies: 2
    Last Post: 26th July 2006, 14:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.