Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-28506

In windows 7 hover QPushButton by mouse increases memory usage.

    XMLWordPrintable

Details

    • 12775b817f4e9f9053b4ea677910dd4101971959

    Description

      When I dragging the mouse over the QPushButton in MS Windows7 (32 and 64bit) my app eats some memory. More moves - more memory used.
      But if I close the widget where the buttons are then memory will be freed, so it's not a simple leak.

      In my test app I'm dragging the mouse over the buttons about 10 minutes and memory grows up to ~500MB.

      When I'm using another QStyle (QWindowsStyle), it does not happens.

      test app

       
      //-- widget1.h
      class Widget1 : public QWidget
      {
       Q_OBJECT
      private:
       void callWidget2();
      public:
       Widget1(QWidget* parent = 0);
       ~Widget1() {}
       
      };
       
      //-- widget1.cpp
      Widget1::Widget1(QWidget* parent)
       :QWidget(parent)
      {
       QPushButton* btn = new QPushButton(this);
       btn->setText("show widget2");
       connect(btn, &QPushButton::clicked, this, &Widget1::callWidget2);
       
       this->resize(100, 100);
       
       this->show();
      }
       
      void Widget1::callWidget2()
      {
       new Widget2();
      }
       
      //-- widget2.h
      class Widget2 : public QWidget
      {
       Q_OBJECT
      private:
       
      public:
       Widget2(QWidget* parent = 0);
       ~Widget2() {}
       
      };
       
      //-- widget2.cpp
      Widget2::Widget2(QWidget* parent)
       :QWidget(parent)
      {
       this->setAttribute(Qt::WA_DeleteOnClose);
       this->resize(300, 300);
       
       QPushButton* button = new QPushButton(this);
       button->setText("btn1");
       
       button = new QPushButton(this);
       button->setText("btn2");
       button->move(0, 20);
       
       button = new QPushButton(this);
       button->setText("btn3");
       button->move(0, 40);
       
       button = new QPushButton(this);
       button->setText("btn4");
       button->move(0, 60);
       
       button = new QPushButton(this);
       button->setText("btn5");
       button->move(0, 80);
       
       this->show();
      }
       
      //-- main.cpp
      int main(int argc, char *argv[])
      {
       QApplication a(argc, argv);
       
       //a.setStyle(new QWindowsStyle); // it solves the problem but looks bad.
       new Widget1;
       
       return a.exec();
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            anaksimandr Andreenko Sergey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes