MDI Window, CreateDIBSection() failed. ()



  • does anybody know why I get this error when I try to create my mdi subwindow?
    "QWindowsXPStylePrivate::buffer(16777215x396), CreateDIBSection() failed. ()"
    not only does it throw this error but my subwindow fails to draw itself properly.

    this is my current code..
    childwindow.h

    #ifndef CHILDWINDOW_H
    #define CHILDWINDOW_H
    
    #include <QtGui>
    #include <QWidget>
    #include <QMdiSubWindow>
    
    #include "screeneditorform.h"
    
    namespace Ui
    {
        class ChildWindow;
    }
    
    class ChildWindow : public QMdiSubWindow
    {
        Q_OBJECT
    
        public:
            explicit ChildWindow(QWidget *parent = 0);
            ~ChildWindow();
    
        private:
            ScreenEditorForm *screenEditorForm;
    };
    
    #endif // CHILDWINDOW_H
    
    

    mainwindow.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private slots:
        void on_actionClose_triggered();
    
        void on_actionScreen_triggered();
    
    private:
        Ui::MainWindow *ui;
    };
    
    #endif // MAINWINDOW_H
    
    

    screeneditorform.h

    #ifndef SCREENEDITORFORM_H
    #define SCREENEDITORFORM_H
    
    #include <QWidget>
    
    namespace Ui {
    class ScreenEditorForm;
    }
    
    class ScreenEditorForm : public QWidget
    {
        Q_OBJECT
    
    public:
        explicit ScreenEditorForm(QWidget *parent = 0);
        ~ScreenEditorForm();
    
    private:
        Ui::ScreenEditorForm *ui;
    };
    
    #endif // SCREENEDITORFORM_H
    
    

    childwindow.cpp

    #include "childwindow.h"
    #include "screeneditorform.h"
    
    ChildWindow::ChildWindow(QWidget *parent) : QMdiSubWindow(parent)
    {
        screenEditorForm = new ScreenEditorForm(this);
        this->setWidget(screenEditorForm);
    }
    
    ChildWindow::~ChildWindow()
    {
       screenEditorForm->~ScreenEditorForm();
    }
    
    

    mainwindow.cpp

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "childwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        //ui->dockWidget->setTitleBarWidget(new QWidget());
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    
    void MainWindow::on_actionClose_triggered()
    {
        this->close();
    }
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    // ToolBar
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    void MainWindow::on_actionScreen_triggered()
    {
        ChildWindow *childWindow = new ChildWindow(ui->mdiArea);
        childWindow->setAttribute(Qt::WA_DeleteOnClose);
        childWindow->show();
    }
    
    

    screeneditorform.cpp

    #include "screeneditorform.h"
    #include "ui_screeneditorform.h"
    
    ScreenEditorForm::ScreenEditorForm(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::ScreenEditorForm)
    {
        ui->setupUi(this);
    }
    
    ScreenEditorForm::~ScreenEditorForm()
    {
        delete ui;
    }
    
    

    main.cpp

    #include <QApplication>
    #include <QFile>
    
    #include "mainwindow.h"
    
    int main(int argc, char *argv[])
    {
        //Q_INIT_RESOURCE(mdi);
    
        QApplication a(argc, argv);
        MainWindow w;
    
    //    // Load an application style
    //    QFile styleFile( ":/Resources/Styles/Style.qss");
    //    styleFile.open( QFile::ReadOnly );
    
    //    // Apply the loaded stylesheet
    //    QString style( styleFile.readAll() );
    //    a.setStyleSheet( style );
    
    
    
        w.setWindowState(Qt::WindowFullScreen);
        w.show();
    
        return a.exec();
    }
    
    

  • Moderators

    @Shadowblitz16 Out of curiosity I did some quick googling and it seems like that error is usually caused by a bad BITMAPINFO struct or, the more likely here, too big of an image being loaded.

    What is ScreenEditorForm doing in it's UI? Is it loading something large?

    Also, this could be a bug if it's easy to reproduce you could submit a small example in a bug report to Qt. I would do some more investigating on the issue before I went that route though. My guess is it has to do with what you are loading into those MDI windows that is causing it.



  • Thankyou ambershark I fixed the error. it was caused by a horizontal spacer with a sizeHint with a very large width.
    however I cannot seem to figure out why the subwindow is not drawing correctly.
    it looks fine untill I move it, but if I do it looks like the MDI container doesn't clear the background and the subwindow doesn't update properly.

    I would be willing to post my ui files if that helps fix this problem.

    EDIT: I just realized that maximizing the subwindow and minimizing it fixes the problem.
    so it could be something with the subwindow initialization?

    EDIT2 It seems that when I open a ton of subwindows its fixes it as well, but when I close them all out and open the first one again the problem reoccurs.

    EDIT3: here is a pic of whats happening: http://imgur.com/a/7ENfd


  • Qt Champions 2016

    @Shadowblitz16 said in MDI Window, CreateDIBSection() failed. ():

    Why are doing this?

    screenEditorForm->~ScreenEditorForm();
    

    It looks bogus.



  • it was in the tutorial and I was just following it.


  • Qt Champions 2016

    @Shadowblitz16 said in MDI Window, CreateDIBSection() failed. ():

    it was in the tutorial

    What tutorial?



  • @kshegunov sorry I thought I linked it in the first post. here it is: http://sys-exit.blogspot.com/2013/02/qt-menu-mdi-child-window-example.html


  • Qt Champions 2016

    It may be unrelated, but you should remove that, the tutorial's wrong. You should not call the destructor explicitly. Just delete the object with delete whenever you're finished using it, or better yet use QObject::deleteLater.



  • I removed the line "screenEditorForm->~ScreenEditorForm();" in the ChildWindow Deconstructor
    however this doesn't fix the window drawing bug.

    I think someone need to make a in depth tutorial video on how to make these mdi forms.

    I think your right, the tutorial is crap.

    EDIT: I got this working besides the styles turns out the tutorial was crap.
    http://imgur.com/a/bHtxd

    I basicly did this to add a subwindow..

    void MainWindow::on_actionScreen_triggered()
    {
        ScreenForm* screenForm = new ScreenForm;
        ui->mdiArea->addSubWindow(screenForm); //screenForm is the widget I want inside of the subwindow
        screenForm->show();
    }
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.