Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MDI Window, CreateDIBSection() failed. ()
QtWS25 Last Chance

MDI Window, CreateDIBSection() failed. ()

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 4.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Shadowblitz16S Offline
    Shadowblitz16S Offline
    Shadowblitz16
    wrote on last edited by
    #1

    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();
    }
    
    
    A 1 Reply Last reply
    0
    • Shadowblitz16S Shadowblitz16

      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();
      }
      
      
      A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      @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.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      2
      • Shadowblitz16S Offline
        Shadowblitz16S Offline
        Shadowblitz16
        wrote on last edited by Shadowblitz16
        #3

        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

        kshegunovK 1 Reply Last reply
        0
        • Shadowblitz16S Shadowblitz16

          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

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

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

          Why are doing this?

          screenEditorForm->~ScreenEditorForm();
          

          It looks bogus.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          1
          • Shadowblitz16S Offline
            Shadowblitz16S Offline
            Shadowblitz16
            wrote on last edited by
            #5

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

            kshegunovK 1 Reply Last reply
            0
            • Shadowblitz16S Shadowblitz16

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

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by
              #6

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

              it was in the tutorial

              What tutorial?

              Read and abide by the Qt Code of Conduct

              1 Reply Last reply
              0
              • Shadowblitz16S Offline
                Shadowblitz16S Offline
                Shadowblitz16
                wrote on last edited by
                #7

                @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

                kshegunovK 1 Reply Last reply
                0
                • Shadowblitz16S Shadowblitz16

                  @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

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #8

                  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.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  1
                  • Shadowblitz16S Offline
                    Shadowblitz16S Offline
                    Shadowblitz16
                    wrote on last edited by Shadowblitz16
                    #9

                    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();
                    }
                    
                    1 Reply Last reply
                    2

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved