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. Using different project names results in different UI display speeds
Forum Updated to NodeBB v4.3 + New Features

Using different project names results in different UI display speeds

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 135 Views 1 Watching
  • 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.
  • C Offline
    C Offline
    CoryChen
    wrote last edited by
    #1

    Hello, I encountered a strange problem while testing my UI setup.
    I have a customized widget which is called "MySpanEdit" and it is decorated by using QSS. I create it 10 of them and put them into layout. It takes 120 ms to initialize this page.

    MyWidgetDemo::MyWidgetDemo(QWidget* parent)
      : QWidget(parent)
    {
      QWidget* w = new QWidget(this);
      w->setFixedSize(400, 988);
      QVBoxLayout* vlayout = new QVBoxLayout(w);
      QPushButton* btn_show = new QPushButton("click to show widgets");
      container = new QWidget(w);
      container->setObjectName("ParentWidget");
      container->setStyleSheet("QWidget#ParentWidget{background-color: rgb(255, 255, 255);}");
      vlayout->setContentsMargins(0, 0, 0, 0);
      vlayout->addWidget(btn_show, 40);
      connect(btn_show, &QAbstractButton::clicked, this, &MyWidgetDemo::on_btn_show_clicked);
    }
    
    void MyWidgetDemo::on_btn_show_clicked()
    {
      QVBoxLayout* hlayout = new QVBoxLayout(container);
      QElapsedTimer timer;
      timer.start();
      for (int i = 0; i < 10; i++)
      {
          MySpanEdit* spanedit = new MySpanEdit(container);
          spanedit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
          hlayout->addWidget(spanedit);
      }
      container->show();
      qDebug() << "Widgets set up in " << timer.elapsed() << "ms";
    }
    

    Then I modify my CMakeLists.txt, I just change my project name .It only takes 9 ms to show this page after clicking on the button.

    cmake_minimum_required(VERSION 3.5)
    
    project(MyWidgetTest VERSION 0.1 LANGUAGES CXX)
    # ... and so on project name
    
    

    I also try to change the the widget "MySpanEdit" into "QSlider" which is the built in widget in Qt. If I new 10 QSliders, different project names result in 6ms and 0ms being displayed respectively. Why change a project name lead to dramatically difference?
    P.S. I'm working on QtCreator 13.0.1 with Qt6.6.3 and MSVC 2019 64bit.

    JonBJ 1 Reply Last reply
    0
    • C CoryChen

      Hello, I encountered a strange problem while testing my UI setup.
      I have a customized widget which is called "MySpanEdit" and it is decorated by using QSS. I create it 10 of them and put them into layout. It takes 120 ms to initialize this page.

      MyWidgetDemo::MyWidgetDemo(QWidget* parent)
        : QWidget(parent)
      {
        QWidget* w = new QWidget(this);
        w->setFixedSize(400, 988);
        QVBoxLayout* vlayout = new QVBoxLayout(w);
        QPushButton* btn_show = new QPushButton("click to show widgets");
        container = new QWidget(w);
        container->setObjectName("ParentWidget");
        container->setStyleSheet("QWidget#ParentWidget{background-color: rgb(255, 255, 255);}");
        vlayout->setContentsMargins(0, 0, 0, 0);
        vlayout->addWidget(btn_show, 40);
        connect(btn_show, &QAbstractButton::clicked, this, &MyWidgetDemo::on_btn_show_clicked);
      }
      
      void MyWidgetDemo::on_btn_show_clicked()
      {
        QVBoxLayout* hlayout = new QVBoxLayout(container);
        QElapsedTimer timer;
        timer.start();
        for (int i = 0; i < 10; i++)
        {
            MySpanEdit* spanedit = new MySpanEdit(container);
            spanedit->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
            hlayout->addWidget(spanedit);
        }
        container->show();
        qDebug() << "Widgets set up in " << timer.elapsed() << "ms";
      }
      

      Then I modify my CMakeLists.txt, I just change my project name .It only takes 9 ms to show this page after clicking on the button.

      cmake_minimum_required(VERSION 3.5)
      
      project(MyWidgetTest VERSION 0.1 LANGUAGES CXX)
      # ... and so on project name
      
      

      I also try to change the the widget "MySpanEdit" into "QSlider" which is the built in widget in Qt. If I new 10 QSliders, different project names result in 6ms and 0ms being displayed respectively. Why change a project name lead to dramatically difference?
      P.S. I'm working on QtCreator 13.0.1 with Qt6.6.3 and MSVC 2019 64bit.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @CoryChen
      There is no obvious reason why project name should make any difference. Did you try (a) repeating your timings over many tests and (b) swapping the order you test them, so the current "faster" one is tested first and the "slower" one tested next, to allow for possible "caching" affecting the timing behaviour?

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CoryChen
        wrote last edited by CoryChen
        #3

        @JonB Thank you for answering me.
        (a) I try to set my widget in a ScrollArea and use button to create or delete it repeatedly. The widget still shows ten times slower than using new project name.
        (b) I change the project name over and over again. Only a certain name cause this kind of delay. I know it doesn't make sense, but it really happened.
        I doubt that StyleSheet may cause this trouble. Should I breakdown my project more detail?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SimonSchroeder
          wrote last edited by
          #4

          Is one of the projects built in debug mode and the other in release mode?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CoryChen
            wrote last edited by
            #5

            Hi @SimonSchroeder
            Nope. I build the projects in Release mode.

            1 Reply Last reply
            0

            • Login

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