Recent

Author Topic: [Answered] Works Fine With GTK2, Not So Fine With QT  (Read 4950 times)

Rails

  • Guest
[Answered] Works Fine With GTK2, Not So Fine With QT
« on: May 17, 2012, 04:17:29 pm »
I am getting unexpected results when building for QT. Everything works fine with GTK2, but with QT the following code snippet does not produce the expected line. The grid layer, generated in another procedure,  is displayed properly.

Strangely the timer results are as expected, indicating everything is processing normally, other than taking somewhat longer than when compiled with GTK2. The line just isn't being drawn on the screen.


Code: [Select]
  Up  :begin                                    // Mouse button up, part of case statement
      if (x1 <> x2) or (y1 <> y2) then         // If yes, then draw the completed line on the main layer
        begin
        StartTimer;                                      // Epik timer measures how long it takes to redraw the form   
        form1.image.Fill(uPrefs.bkgnd);         // Required, prevents dimming of existing lines
        form1.mainLayer.DrawLineAntiAlias(x1, y1, x2, y2, BGRABlack, 1.0);                  // Works with GTK2, but not QT
        form1.image.PutImage(0, 0, form1.gridLayer, dmDrawWithTransparency);           // Grid layer is drawn in another procedure
        form1.image.PutImage(0, 0, form1.mainLayer, dmDrawWithTransparency);     
        form1.image.Draw(form1.Canvas, 0, 0, False);
        CheckTimer;                                                                                                 // Writes the ET to the status panel
        end;
      end;                   

I do notice a warning when compiling for QT:

..../BGRABitMap/bgrabitmap5.7/bgraqtbitmap.pas(146,4) Warning: User defined: QT: recheck this

I get exactly the same results on two different machines with completely different graphics processors.

Any thoughts?

Linux
Laz 1.1
FPC 2.6.0
« Last Edit: May 17, 2012, 11:17:29 pm by Rails »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7641
Re: Works Fine With GTK2, Not So Fine With QT
« Reply #1 on: May 17, 2012, 04:22:24 pm »

Just guessing:

Invalidate the image or form ?

You draw to a backbuffer, and apparently, it doesn't trigger a redraw event

Rails

  • Guest
Re: Works Fine With GTK2, Not So Fine With QT
« Reply #2 on: May 17, 2012, 04:49:36 pm »
Invalidating the image (InvalidateBitmap) has no effect.

Invalidating the form does cause the line to show, but the delay is unacceptable, rendering the app unusable. For whatever reason, GTK does not require this.


Blaazen

  • Hero Member
  • *****
  • Posts: 2782
  • POKE 54296,15
    • Eye-Candy Controls
Re: Works Fine With GTK2, Not So Fine With QT
« Reply #3 on: May 17, 2012, 04:54:50 pm »
Some widgetset enables to draw out of Paint method (Gtk2, Win) and the others don't (Qt, Carbon). Isn't this that case ?
Lazarus 2.1.0 r61214:62238 FPC 3.3.1 r40507 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Rails

  • Guest
Re: Works Fine With GTK2, Not So Fine With QT
« Reply #4 on: May 17, 2012, 05:44:19 pm »
OK, I commented out:

// form1.image.Draw(form1.Canvas, 0, 0, False);

and tried instead:

form1.Repaint

This works in both QT and GTK. However it isn't usable due to skipping between the repaint events. Invalidating the form seems even worse.

There is a delay between the Repaints. During the delay, cursor movement seems to be lost. That's the best I can describe it.
« Last Edit: May 17, 2012, 06:39:03 pm by Rails »

Rails

  • Guest
[Answered] Works Fine With GTK2, Not So Fine With QT
« Reply #5 on: May 17, 2012, 11:16:52 pm »
It appears both Blaazen and Marcov were correct. Thank you both. Invalidate is required for QT, but not for GTK2. Circular mentioned this point in another thread, but it went over my head.  :-[
However, investigating this has raised other issues regarding the speed of redrawing the bitmap and/or form, at least for what I am doing. I think it is best to address that problem in a new thread.
« Last Edit: May 17, 2012, 11:23:22 pm by Rails »

circular

  • Hero Member
  • *****
  • Posts: 3058
    • Personal webpage
Re: [Answered] Works Fine With GTK2, Not So Fine With QT
« Reply #6 on: May 18, 2012, 05:26:49 pm »
You can use BGRAVirtualScreen component of BGRAControls.
http://wiki.freepascal.org/BGRAControls#TBGRAVirtualScreen
Conscience is the debugger of the mind

Rails

  • Guest
Re: [Answered] Works Fine With GTK2, Not So Fine With QT
« Reply #7 on: May 18, 2012, 08:09:28 pm »
You can use BGRAVirtualScreen component of BGRAControls.
http://wiki.freepascal.org/BGRAControls#TBGRAVirtualScreen

As it happens, I just started a test project using TBGRAVirtualScreen.

I reread your earlier post in the other thread.  :D

circular

  • Hero Member
  • *****
  • Posts: 3058
    • Personal webpage
Re: [Answered] Works Fine With GTK2, Not So Fine With QT
« Reply #8 on: May 19, 2012, 08:49:20 pm »
Alright.  8-)
Conscience is the debugger of the mind