Nominate our 2022 Qt Champions!

[Solved] Update nonactive window in Qt 4.

  • I have a nonactive window that is visible. I have an active window that sends data to the nonactive window that uses it to update controls in the window. If I use update() the nonactive window does not update until it is activated. Is there a function that updates the visible part of a nonactive window?

  • Have you tried the repaint()-function? I'm not sure, but it might work...

  • I have tried repaint() as well. The same results. The nonactive window only updates when it becomes active. I tried to use QApplication::processEvents(0), but I get an error when I build it. The error is:

    MainForm.cpp:933: error: incomplete type 'QApplication' used in nested name specifier

  • I was able to call repaint() of the inactive window and it worked fine.

    can you post some sample code where it is failing to repaint?

    void ChildWindow::paintEvent(QPaintEvent *pe)
    qDebug() << "My window name is" << wName() << " " << flag;
    if (flag)
    qDebug() << "inside paint of childwindow: " << wName();
    MainWindow::clik1(); //this method changes button names

    void ChildWindow::setFlag()
    flag = true;

    void ChildWindow::updateWin(ChildWindow *w)
    qDebug() << "firing single shot now from active window";
    QTimer::singleShot(5000, w, SLOT(setFlag()));

    this is how I called the 2 child windows ...
    ChildWindow c;
    c.setWName(new QString("c"));

    ChildWindow c1;
    c1.setWName(new QString("c1"));


  • Thanks for the reply. The program now works.

  • ah cool, what made it not to work earlier? could you share that info ?

Log in to reply