Forum > QT

(solved) Translucent Window in Qt but the anchor doesn't work properly

(1/1)

AFFRIZA 亜風実:
So, I just playing with Qt5 to make window translucent. Since the Lazarus's Alpha Blend property makes everything translucent so I using Qt5 functions directly to do that. Here's the code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin   QWidget_setVisible(TQtMainWindow(Self.Handle).GetContainerWidget, false);  TQtWidget(Panel1.Handle).setParent(TQtMainWindow(Self.Handle).Widget);  QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);  Panel1.Align:=alClient; end; But, when I resized the window, something is strange the panel that I've set to use alClient didn't resize when I resized the window. Strangely, when I move the window it resized, the action is kinda late (I guess?). May someone know to make that to behave normally in translucent window?  :-[

Anyway, I don't know if the ContainerWidget also can be set as translucent. Now, by doing that is translucent as well.
Here's the change:  :D

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);  QWidget_setAttribute(TQtMainWindow(Self.Handle).GetContainerWidget, QtWA_TranslucentBackground);end; 

zeljko:
Please attach complete example project.

AFFRIZA 亜風実:

--- Quote from: zeljko on May 30, 2022, 11:06:07 am ---Please attach complete example project.

--- End quote ---
Hello, zeljko. Thanks for the reply.

Here's the example.

AFFRIZA 亜風実:
Anyway, I don't know if the ContainerWidget also can be set as translucent. Now, by doing that is translucent as well.
Here's the change:  :D

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  QWidget_setAttribute(TQtMainWindow(Self.Handle).Widget, QtWA_TranslucentBackground);  QWidget_setAttribute(TQtMainWindow(Self.Handle).GetContainerWidget, QtWA_TranslucentBackground);end; 
Why I didn't thinking about doing this before  :'(

Navigation

[0] Message Index

Go to full version