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. How to avoid QWidget show the default background before paintEvent be called
Forum Updated to NodeBB v4.3 + New Features

How to avoid QWidget show the default background before paintEvent be called

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 428 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.
  • W Offline
    W Offline
    wgong
    wrote on last edited by
    #1

    Envirment

    Win10 + Qt15.4.2 + QWidget Application

    Problem

    I Create a empty QWidget Application,and put some child widget on it, the rewrite it's paintEvent to fill window to blue.
    But when run the program,I found:

    int main(int argc, char* argv[]){
        QApplication a(argc, argv);
        MyWidget w;
        w.show();    //After this, w.paintEvent is not called, the widget is shown using default style,such as a white background,but the child widget isn't shown.
        a.exec();    //After this, w.paintEvent is called, the background is be painted to blue. and child widget is shown.
    }
    

    That is when start, white background without child widget is shown first, soon, it changed to blue background with all child widget. A serious flash。

    Question

    How can we avoid this flash? Is it possible to show the widget with all child is shown and paintEvent had been called?

    JoeCFDJ 1 Reply Last reply
    0
    • W Offline
      W Offline
      wgong
      wrote on last edited by
      #2

      And I found the official example of Qt: Style Example is the same。

      Example

      example.png

      After show() and before exex():

      before.png

      After exec():

      after.jpg

      Christian EhrlicherC 1 Reply Last reply
      0
      • W wgong

        And I found the official example of Qt: Style Example is the same。

        Example

        example.png

        After show() and before exex():

        before.png

        After exec():

        after.jpg

        Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @wgong You can't. Show sends an event to the window manager and it is showing the decoration. It's just a debugging issue.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        W 1 Reply Last reply
        0
        • W wgong

          Envirment

          Win10 + Qt15.4.2 + QWidget Application

          Problem

          I Create a empty QWidget Application,and put some child widget on it, the rewrite it's paintEvent to fill window to blue.
          But when run the program,I found:

          int main(int argc, char* argv[]){
              QApplication a(argc, argv);
              MyWidget w;
              w.show();    //After this, w.paintEvent is not called, the widget is shown using default style,such as a white background,but the child widget isn't shown.
              a.exec();    //After this, w.paintEvent is called, the background is be painted to blue. and child widget is shown.
          }
          

          That is when start, white background without child widget is shown first, soon, it changed to blue background with all child widget. A serious flash。

          Question

          How can we avoid this flash? Is it possible to show the widget with all child is shown and paintEvent had been called?

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #4

          @wgong Qt15.4.2 does not exist. Is it Qt5.14.2? If yes, upgrade your Qt to at least 5.15.2 first. Is your screen a touch screen?

          W 2 Replies Last reply
          0
          • JoeCFDJ JoeCFD

            @wgong Qt15.4.2 does not exist. Is it Qt5.14.2? If yes, upgrade your Qt to at least 5.15.2 first. Is your screen a touch screen?

            W Offline
            W Offline
            wgong
            wrote on last edited by
            #5

            @JoeCFD , 5.14.2 is right. I am sorry, it's a clerical error. I will try other version later,and hope somethind is different.thanks.

            1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              @wgong You can't. Show sends an event to the window manager and it is showing the decoration. It's just a debugging issue.

              W Offline
              W Offline
              wgong
              wrote on last edited by
              #6

              @Christian-Ehrlicher
              Thanks for reply. But it not only a debug issue. I test the release mode, the default background appears first, then final background.obvious flash,same as the debug mode.

              1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @wgong Qt15.4.2 does not exist. Is it Qt5.14.2? If yes, upgrade your Qt to at least 5.15.2 first. Is your screen a touch screen?

                W Offline
                W Offline
                wgong
                wrote on last edited by
                #7

                @JoeCFD
                oh, I am not a touch screen. It is a pc with a monitor.

                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