Set CullFace to Front and Back in Qt3D in Python via PySide2 - python-3.x

I wanted to set QCullFace to FrontAndBack and that is why I wrote this:
from PySide2.Qt3DRender import Qt3DRender
cull_face = Qt3DRender.QCullFace()
cull_face.setMode(Qt3DRender.QCullFace.FrontAndBack)
render_pass = Qt3DRender.QRenderPass()
render_pass.addRenderState(cull_face)
The code above should set CullFace globally. But it does not. What did I do wrong?

I assume that the python binding does not change how Qt works in C++.
So you probably have a Qt3DWindow somewhere (unless you render to an offscreen or your own surface). If you want your cull face to be active, you have to retrieve the QRenderSettings from the window by calling renderSettings(). The render settings hold the active framegraph, i.e. if you want any render states or anything else that is related to the framegraph to be active, it has to be a child of the node that the render settings hold as active framegraph. You can get and set the active framegraph on the render settings by calling activeFramegraph() or setActiveFramegraph(QFramegraphNode*).
Is there a reason why you use QRenderPass? Because if yes, you have to create a QRenderPassFilter, in order to set it as the active framegraph on the render settings (QRenderPass does not inherit QFramegraphNode). This way you can filter out certain objects from the render pass.
But since you want the cull face to be active globally I'd suggest that you use a QRenderStateSet and add the QCullFace there. You can then set the render state set as the active framegraph on the render settings of the 3D window.

Related

How to force Godot to recalculate control nodes size/position?

Building UI in Godot 3.2.1. Of course I use anchors so UI elements are arranged within the screen automatically according to specified layout. I have UI scale system - nothing fancy - simply change font size (DynamicFont.size). If font size is large enough then some UI nodes may be pushed out of the screen. However, nodes don't return to normal sizes/positions with font size decreasing. The way to fix a mess is to resize game window which is not always an option and doesn't seem like a correct way to handle the issue. So how can I force Godot to recalculate control nodes size/position?
Changing the parent control's minimum size to Vector2(0, 0) after changing the font size might do the trick:
$Control.rect_min_size = Vector2(0, 0)
If it's already set to Vector2(0, 0), you may have to change it twice using call_deferred() for it to work.
In your scene tree, find the top level container that contains all of the elements that you want to recalculate. This would be the lowest common ancestor in the scene tree, in computer science terminology. Now, hide the container, by setting it's 'visible' property to false. Then, add a deferred call to change it's 'visible' property back to true.
var your_container = $".".find_node("your-container")
your_container.visible = false
your_container.call_deferred("set_visible", true)
This seems to cause Godot to recalculate the layout of 'your_container'.
It looks like only CanvasItem derived classes have a 'visible' property, so you would not be able to simply set the 'visible' property on a CanvasLayer, for example.
Fortunately, Containers and Controls both derive from CannvasItem, so this methodology should work fine if your lowest common ancestor node is either a Container or a Control or other CanvasItem derived class instance.
I got this working by emitting a signal from a parent element, which appears to force a refresh:
canvas_item.emit_signal("item_rect_changed")
The problem child got refreshed, and unlike the visibility method, focus was retained.

Xpages add a custom control that doesn't take up space (rendered versus loaded versus visible)

I have some custom controls that I want to include in Xpages, but I don't want them to be visible to the user or to take up space on the screen, as it is throwing my alignment off. I have looked at the properties rendered, loaded, and visible, but I don't really understand them and they don't seem to do what I want, which is to include some functionality but not change the layout.
I am sure there is a way to do this, but I can't figure it out.
Loaded means it won't be added to the component tree and only affects server-side functionality. Because it's not in the component tree (the server-side map of the page) it can't be passed to the browser or processed during partial refreshes. Rendered and visible are the same and mean they're in the component tree, so server-side processing can interact with them, but no HTML is passed to the browser for them. So you can't interact with them via CSJS. If you want it passed to the browser, available for CSJS but not visible to the user, you'll need to set the style as display:none. Another option is to put that style in a theme and allocate the themeId you choose to your custom control.

cleanlook style for message box pyqt4

I have an PYQT4 application. I try to display a lot of differnt messages based on user interaction. The problem I have is the displayed message using QMessageBox doest come up in clean look style, whereas the other part of the application works well with Clean look style.
I try to use the following code but it doenst work for the message.
# set messagebox properties
msgbox=QMessageBox()
font = QFont()
font.setFamily(_fromUtf8("Levenim MT"))
font.setPointSize(15)
msgbox.setFont(font)
msgbox.setStyle(QStyleFactory.create('Cleanlooks'))
msgbox.information(self,"Download Message", "donuts")
can someone tell me how to make this in clean look style as well
To change the style of your application, you should use QApplication.setSyle, then you have a consistent style in your whole GUI.
Setting a QWidgets's style only sets the style for the widget itself.
QWidget.setStyle:
Sets the widget's GUI style to style. The ownership of the style object is not transferred.
If no style is set, the widget uses the application's style, QApplication.style() instead.
Setting a widget's style has no effect on existing or future child widgets.
Warning: This function is particularly useful for demonstration purposes, where you want to show Qt's styling capabilities. Real applications should avoid it and use one consistent GUI style instead.
That means if you want to change the style of a widget and all it's children, you need to explicitly set it for all children by iterating through them:
cleanlooks = QStyleFactory.create('cleanlooks')
msgbox.setStyle(cleanlooks)
for child in msgbox.findChildren(QWidget):
child.setStyle(cleanlooks)

QFileIconProvider always use "gnome" theme?

Is there a way to let user choose what icon theme to use , when using QFIleIconProvider ? It looks like Qt uses "gnome" by default , i wanted to change this behavior.
The icon style is dependent on what is returned from QApplication::style(). So if you change the application style using QApplication::setStyle(), you'll get a different set of icons too. If you want a different theme than the application style, you need to subclass QFileIconProvider and set you custom icon provider with QFileSystemModel::setIconProvider(yourCustomIconProvider).

ExtJS 4 - Rendering components that are initially hidden

One major difference that I have noticed between ExtJS 3.x and 4.x is how the rendering/layout calculation is handled for components that are rendered inside of a containing element that has display:none (NOT an Ext created/monitored containing element). In 3.x, upon showing the containing element, the Ext component it contained would be properly rendered and sized to whatever dimensions i set for it.
However, in 4.x, that same component will not be displayed at all and have a zero height and width when its containing element was shown. After it was visible if I do a call to .setSize() it would then properly be displayed. Problem is, in my application there is just no way to be able to go through all the events that could cause a hidden component to be shown, and add code to make sure its layout is manually forced to be recalculated.
So my question is, is there any way to get back 3.x's behavior in this situation for all components across the board in 4.x?
What you can try to do is set up listeners on your components that delegate to the underlying DOM elements, perhaps that will solve your issue.
However my suggestion is if at all possible is to use the framework to manage the entire page layout using Viewport. You can still suck in the HTML (if you must) and render it inside containers or panels for example. Perfect use case here is Header and Footer which are generated by server side code (jsp, gsp, asp..) and then displayed in the North or South regions of the Viewport using contentEl : 'myDivId' configuration.

Resources