0

I have a QDialog which has some settings, on the basis of which, QTreeView or the whole QMainWindow needs to be updated or repainted or refreshed.

QDialog has two buttons:

  • Apply: This button needs to apply the settings to QMainWindow, such as color to QTreeView Columns. This is one example, there are more items such as QTableView etc. on QMainWindow which also needs to be updated on clicking this button.

  • Close: This button hides the QDialog.

I have tried invoking repaint/update function on QMainWindow on clicking Apply Button, but nothing works.

void MainWindow::refresh() 
{
setUpdatesEnabled(true);
setWindowModified(true);
repaint();
update();
show();
}

However, on clicking close button, which calls hide on QDialog, the whole view on QMainWindow gets updated/repainted.

I need to do the exactly same thing on Apply button.

How to achieve this? What is the SLOT that QDialog->hide is calling on QMainWindow?

mehak
  • 57
  • 7

1 Answers1

0

If your colors based on Qt roles you have to refresh data model (look at dataChanged signal) not main window. If your colors based on qt css you can just call QMainWindow::setStyleSheet with new values

Serhiy Kulish
  • 1,057
  • 1
  • 6
  • 8
  • That's right.. But there can be other widgets in QMainWindow except QTreeView which need to be updated. The way close button is working, is exactly the behavior i need to implement. I don't want to manually signal widgets in QMainWindow. Isn't this somehow possible to signal QMainWindow that Widgets has been updated and please repaint QMainWindow? – mehak Sep 20 '18 at 05:18