Как заставить QWidget перерисовываться?C++

Программы на C++. Форум разработчиков
Anonymous
Как заставить QWidget перерисовываться?

Сообщение Anonymous »

При следующей реализации главного окна:

Код: Выделить всё

#include 

#include "MainWindow.h"

namespace ui {
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
child(this) {
this->resize(425, 450);
this->child.move(10, 10);
this->child.resize(400, 400);
}

MainWindow::~MainWindow() {}

void MainWindow::showEvent(QShowEvent* event) {
QWidget::showEvent(event);

qDebug() child.update();
this->child.update();
this->child.update();
this->child.update();
this->child.repaint();
this->child.repaint();
this->child.repaint();
this->child.repaint();
QApplication::processEvents();
}
}  // namespace ui
и виджет, который выглядит следующим образом:

Код: Выделить всё

#include 

#include "Widget.h"

namespace ui {
Widget::Widget(QWidget *parent) :
QWidget(parent) { }

void Widget::paintEvent(QPaintEvent *event) {
qDebug() child.update() и this->child.repaint()  вызывает MainWindow.cpp.
Если update() и repaint() фактически не обновляют и не перерисовывают виджет , что мне следует сделать вместо этого, чтобы принудительно перерисовать виджет? 

Подробнее здесь: [url]https://stackoverflow.com/questions/78718623/how-do-i-force-a-qwidget-to-be-repainted[/url]

Вернуться в «C++»