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. why program is so laggy after using QGraphicsDropShadowEffect
QtWS25 Last Chance

why program is so laggy after using QGraphicsDropShadowEffect

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 5 Posters 1.4k 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.
  • S Offline
    S Offline
    saeid0034
    wrote on 27 Apr 2021, 21:08 last edited by saeid0034
    #1

    Hi here is my code

    QTGui::QTGui(QWidget *parent)
        : QMainWindow(parent),
    	ui(new Ui::MainWindow)
    {
            ui->setupUi(this);
    
    	connect(ui->btn_close, &QPushButton::clicked, this, &QWidget::close);
    	connect(ui->btn_minimize, &QPushButton::clicked, this, &QWidget::showMinimized);
    	connect(ui->btn_maximize_restore, &QPushButton::clicked, this, &QTGui::maximize_restore);
    
    	QGraphicsDropShadowEffect* windowShadow = new QGraphicsDropShadowEffect;
    	windowShadow->setBlurRadius(9.0);
    	windowShadow->setColor(palette().color(QPalette::Highlight));
    	windowShadow->setOffset(0.0);
    	ui->frame_main->setGraphicsEffect(windowShadow);
    
            ui->frame_label_top_btns->installEventFilter(this);
    }
    

    I dont know why, but my program become so laggy after using QGraphicsDropShadowEffect
    can anyone tell me what is my problem?
    thanks

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nagesh
      wrote on 27 Apr 2021, 23:53 last edited by
      #2

      @saeid0034 confirm that behaviour is due to QGraphicsDropShadowEffect by disabling the graphics effect.

      ui->frame_main->graphicsEffect()->setEnabled(false);

      https://doc.qt.io/archives/qt-4.8/qgraphicseffect.html#enabled-prop
      //Using this property, you can disable certain effects on slow platforms, in order to ensure that the user interface is responsive.

      As per Qt docs

      Effects alter the appearance of elements by hooking into the rendering pipeline and operating between the source (e.g., a QGraphicsPixmapItem) and the destination device (e.g., QGraphicsView's viewport).
      
      1 Reply Last reply
      1
      • S Offline
        S Offline
        saeid0034
        wrote on 28 Apr 2021, 09:05 last edited by saeid0034
        #3

        yes, I tested it, when I disabled QGraphicsDropShadowEffect program work normally (its no longer laggy or slow). what can I do to use shadow in my program widget without any performance issues?
        I created a frameless window and I want to use shadow for it

        1 Reply Last reply
        0
        • S Offline
          S Offline
          saeid0034
          wrote on 14 Jul 2021, 19:25 last edited by
          #4

          I still have this problem, no matter what i do, when Im using shadow its make my program laggy...
          there is any fix??

          M 1 Reply Last reply 14 Jul 2021, 19:55
          0
          • S saeid0034
            14 Jul 2021, 19:25

            I still have this problem, no matter what i do, when Im using shadow its make my program laggy...
            there is any fix??

            M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 14 Jul 2021, 19:55 last edited by
            #5

            @saeid0034
            Hi
            sadly i dont think its fixable as QGraphicsDropShadowEffect must be too heavy
            for your device to handle then.

            S 1 Reply Last reply 14 Jul 2021, 19:57
            1
            • M mrjj
              14 Jul 2021, 19:55

              @saeid0034
              Hi
              sadly i dont think its fixable as QGraphicsDropShadowEffect must be too heavy
              for your device to handle then.

              S Offline
              S Offline
              saeid0034
              wrote on 14 Jul 2021, 19:57 last edited by saeid0034
              #6

              @mrjj I tested it in other pc too, but result was the same, in fact program doesn't use much of resource at all

              M 1 Reply Last reply 14 Jul 2021, 21:13
              0
              • S saeid0034
                14 Jul 2021, 19:57

                @mrjj I tested it in other pc too, but result was the same, in fact program doesn't use much of resource at all

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 14 Jul 2021, 21:13 last edited by
                #7

                @saeid0034

                So the lag comes at normal pc ? not a small device ?

                S 1 Reply Last reply 14 Jul 2021, 21:35
                1
                • M mrjj
                  14 Jul 2021, 21:13

                  @saeid0034

                  So the lag comes at normal pc ? not a small device ?

                  S Offline
                  S Offline
                  saeid0034
                  wrote on 14 Jul 2021, 21:35 last edited by
                  #8

                  @mrjj yes exactly, program running in pc

                  M 1 Reply Last reply 15 Jul 2021, 06:03
                  0
                  • S saeid0034
                    14 Jul 2021, 21:35

                    @mrjj yes exactly, program running in pc

                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 15 Jul 2021, 06:03 last edited by
                    #9

                    @saeid0034

                    Ok ?! What kind of PC are we talking about ?
                    I mean CPU, amount of ram and GFX card.

                    Did you try a default GUI project with the effect only to see ?
                    I mean so app really does nothing and just has this effect.
                    To see if that also lags.

                    1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      saeid0034
                      wrote on 15 Jul 2021, 13:54 last edited by
                      #10

                      @mrjj with program open: a custom progress bar and shadow program use this much of resource
                      bf36dc30-e1c5-439b-9459-1b28d79033b0-image.png
                      as You can see its not using much of resource at all (except power usage... maybe its because progress bar, its on IndeterminateProgress mode...)

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        saeid0034
                        wrote on 15 Jul 2021, 14:05 last edited by saeid0034
                        #11

                        its also much less in release build (previous one was debug)
                        f0e61398-5274-4965-9c1b-2e3090dab5d6-image.png

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          drewski628
                          wrote on 13 Oct 2022, 12:49 last edited by
                          #12

                          I have experienced this slow down as well on a PC ..

                          Processor 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz 2.50 GHz
                          Installed RAM 32.0 GB (31.6 GB usable)

                          My current approach is not using the drop shadow effect...(which I would like)

                          1 Reply Last reply
                          0
                          • M Offline
                            M Offline
                            moses-molina
                            wrote on 4 Dec 2022, 18:23 last edited by
                            #13

                            I'm seeing the same issue in a small game running PySide6 on an apple M1 Macbook Pro. 200-300 FPS without drop shadow effect enabled, and 30FPS with. One solution for my use case may be to bake the effect into an image asset and draw that instead. I don't need the functionality of the QGraphicsDropShadowEffect during runtime, just the look.

                            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