0

I have a Qt Application built with Qt Creator. I have check boxes on different tabs of a QTabWidget, and it has a video display window. It is keeps my computer pretty busy.

When I click on a checkbox, the check on the checkbox takes a while to show up. If I quickly check the box and move my mouse away, the "check" in the box does not show up. I need to mouse over the check-box again for the check to be shown.

I have added a stateChanged() function for the "Display_box_fit" check box. When I update the text associated with the check box, this happens right away. I can set the state of another check box and the check in this box happens right away. However, the check for the "Display_box_fit" is slow, and if I mouse away (ie out of focus for the check-box), the check is never displayed on the check box. No amount of repaint() calling in the "Display_box_fit_stateChanged()" function seems to fix the problem.

I have googled the problem for far too long and have found no good solutions. It seems like a pretty fundamental issue.

Is there someway to get this to work without requiring the user to re-mouse over the checkbox to see its state?

I am using visual studio under windows with Qt5 under c++

Code:

void on_Display_box_fit_stateChanged(){
  if (ui.Display_box_fit->isChecked()){
    ui.Display_box_fit->setText("pushed");
    ui.Display_box_fit->setChecked(true);   // tried this .. no affect
  }else{
    ui.Display_box_fit->setText("no pushed");   // text updated "immediately"
  }
  ui.Display_box_fit_2->toggle();   // this check appears "immediately"

  // tried all kinds or repaint() ... does not seem to help
  ui.tabWidget->currentWidget()->repaint();
  //ui.Display_box_fit->repaint();
  //ui.Display_box_fit->parentWidget()->repaint();
  //ui.Display_box_fit->parentWidget()->parentWidget()->repaint();
  //ui.tabWidget->setCurrentWidget(ui.tab_debug);
  //ui.tabWidget->setCurrentWidget(ui.tab_Display);
};

Note1: The setChecked(true) was an attempt to get Qt to render the check Mark in the box. Unfortunately, it had no affect on the rendering and can be removed.

Note2: building an example is quite difficult. I believe it is a function of how loaded the computer is. If I step through the code above in the debugger I see that the repaint() updates the text on the widget, but does not update the check mark on the widget.

Is there some function I can call which will update the check marks?

wainCam
  • 11
  • 2
  • why do you call setChecked if to enter that if it must be checked. If you want us to help you, you must provide a [mcve] – eyllanesc Feb 11 '18 at 21:12
  • 1
    `repaint`? You doing something terribly wrong. Show more code or provide a link to your whole project. – Marek R Feb 13 '18 at 00:04

0 Answers0