0

I have an application that have a main window with an MDI area that uses the whole window. When the application is opened it is not maximized. If i open the child window and then close it, the ghost of the window still shows. If i open a another child window and then move it across the MDI area you get copies of the window one on top of each other only in the area where the ghost was.
If i open the main window, then maximize it, open the child and maximize it, this problem disappears. Then a can get the main window to the original size, open and close child windows, move them around and the background is redrawn correctly.
Is there anything that can be done to solve this behavior? Calling the mdi window:

void PriceAnalysisTool::on_actionImport_triggered()
{
    importprocess = new ImportProcess(working, printer, ui->mdiArea);

    importprocess->show();
}

And the initial part of the sub window:

ImportProcess::ImportProcess(DataBase *d, QPrinter *p, QWidget *parent) : QMdiSubWindow(parent), ui(new Ui::ImportProcess)
{
  ui->setupUi(this);

Test program showing the same behavior:
main window:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QDebug>
#include "subwindow.h"

namespace Ui {
  class MainWindow;
}
class MainWindow : public QMainWindow
{
  Q_OBJECT
public:
  explicit MainWindow(QWidget *parent = 0);
  ~MainWindow();
private slots:
  void on_actionOpen_Window_triggered();
private:
  Ui::MainWindow *ui;
  SubWindow *subwindow;
};

#endif // MAINWINDOW_H

main window.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
  ui->setupUi(this);
}

MainWindow::~MainWindow()
{
  delete ui;
}


void MainWindow::on_actionOpen_Window_triggered()
{
   subwindow = new SubWindow(ui->mdiArea);
   subwindow->show();
}

subwindo.h

#ifndef SUBWINDOW_H
#define SUBWINDOW_H

#include <QWidget>
#include <QMdiSubWindow>

namespace Ui {
  class SubWindow;
}

class SubWindow : public QMdiSubWindow
{
  Q_OBJECT

public:
  explicit SubWindow(QWidget *parent = 0);
  ~SubWindow();

private:
  Ui::SubWindow *ui;
};

#endif // SUBWINDOW_H

subwindw.cpp

#include "subwindow.h"
#include "ui_subwindow.h"

SubWindow::SubWindow(QWidget *parent) : QMdiSubWindow(parent), ui(new Ui::SubWindow)
{
  ui->setupUi(this);
}

SubWindow::~SubWindow()
{
  delete ui;
}

main.cpp

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  MainWindow w;
  w.show();

  return a.exec();
}

the ui for the main window has only has a MDI are and the a menu with a single item that calls the subwindow. The subwindow is a widget that has nothing on it.

{
  QSqlQuery query;
  query.exec("drop table C"+QString::number(markTime.toSecsSinceEpoch()));
  query.exec("drop table C"+QString::number(markTime.toSecsSinceEpoch())+"T");
  query.exec("drop table C"+QString::number(markTime.toSecsSinceEpoch())+"S");
  query.exec("drop table C"+QString::number(markTime.toSecsSinceEpoch())+"F");
  delete ui;
}
ymoreau
  • 3,402
  • 1
  • 22
  • 60
Dan3460
  • 95
  • 3
  • 13
  • It would be easy to solve this problem if you put your code – Vahagn Avagyan Aug 03 '17 at 11:50
  • Is huge, just the MDI sub window is over 800 lines. I'm guessing this is not a common problem. Don't know which parts you will be interested in. I posted a couple of excerpts on the original question. – Dan3460 Aug 03 '17 at 12:05
  • Do you use the closeEvent() in the MID? – Vahagn Avagyan Aug 03 '17 at 12:23
  • Yes i do, i will post that on the question. I just made a small test program that shows the same behavior. will post that too. – Dan3460 Aug 03 '17 at 12:26
  • I'm still interested , From whom is inherited the MID class? And show please your closeEvent() function – Vahagn Avagyan Aug 03 '17 at 12:33
  • Try it so , explicit SubWindow(); explicit MainWindow(); empty constricktor, And you did not show how to close the child window?? – Vahagn Avagyan Aug 03 '17 at 12:51
  • Sorry i didn't get that. The test program has the same behavior, the destructor on the child window is that same as in the original program. Added the original destructor – Dan3460 Aug 03 '17 at 13:10

0 Answers0