Some Qt questions

   20853   24   7
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Hi, dear SESI team !!!

Python Panel is very good addition to Houdini, but:

1. How to set main houdini widget as parent of my own widget?

2. I installed eventfilter to main widget for monitoring Qt ui behaviour. And i saw that not all events can catch.
For example, Leave event (when we go to other top level widget). I dont understand why Leave event not generated in this case

3. As I understood, Qt draw Houdini old-style UI system, and we can`t add for example QPushButton to main window. Or maybe this can changed in future releases



Also, I think that we need some identification method of main Houdini widget via PySide. For example, in Maya we can filter widget via objectName (QtGui.QWidget.objectName). In HDK I can get it with RE_QtWindow::mainQtWindow()

Thanks for any details about Qt…



PS Look at this level of PyQt\PySide intervention

http://youtu.be/Mu_tVZJYYBQ [youtu.be]

What do you think?


Best regards…
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
please, any Qt details…
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
SESI, please give us some details on Qt implementation.
- QFont not working.Can't change font size on widgets. setStyleSheet not working.
- Colors of widgets look weird (problem with QStyle?)
- dropEvent for houdini operators doesn't work.
Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
User Avatar
Staff
1255 posts
Joined: July 2005
Offline
Hello,

vux
1. How to set main houdini widget as parent of my own widget?

To attach your widget to a Python Panel you just have to ‘return’ it from the createInterface() function.

For example in the Script section of your Python Panel interface you can write:

from PySide import QtGui

def createInterface():
widget = QtGui.QLabel('Hello World!')
return widget


Also I'm not sure if you've seen this help page already:
http://www.sidefx.com/docs/houdini14.0/ref/windows/pythonpaneleditor [sidefx.com]

It contains information about creating and editing interfaces in Python Panels.

Also if you haven't already, try the Quick Start example that's available in the Python Panel by default. That might answer questions about the workflow.

vux
2. I installed eventfilter to main widget for monitoring Qt ui behaviour. And i saw that not all events can catch.
For example, Leave event (when we go to other top level widget). I dont understand why Leave event not generated in this case

There's a bug with Python Panel event filtering that we are currently working on. It should be fixed in a daily build soon.

But it sounds like you are trying to install an event filter on the root widget. This is not recommended or supported. It is best to install filters only on your custom widgets and not the main Houdini widget.

vux
3. As I understood, Qt draw Houdini old-style UI system, and we can`t add for example QPushButton to main window. Or maybe this can changed in future releases

That is correct. Modifying the main window is currently not supported. This is something that we are considering for a future release.

And it sounds like a bug that the HDK currently provides you with access to the main Houdini widget. I will look into that.

vux
PS Look at this level of PyQt\PySide intervention

http://youtu.be/Mu_tVZJYYBQ [youtu.be]

What do you think?

Interesting. You can do something similar in Houdini by dragging parameters into the viewport and creating HUD sliders. Not as sophisticated but still pretty useful.

Cheers,
Rob
User Avatar
Staff
1255 posts
Joined: July 2005
Offline
Hello,

Stalkerx777
- QFont not working.Can't change font size on widgets. setStyleSheet not working.

This is a bug that we're currently looking into.

Stalkerx777
- Colors of widgets look weird (problem with QStyle?)

Hmm. I don't think I'm seeing this.

Which widgets look weird? Can you attach a screenshot? Or post a script example?

Stalkerx777
- dropEvent for houdini operators doesn't work.

This is fixed in the latest H14 daily builds.

Cheers,
Rob
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
rvinluan
Hello,

Stalkerx777
- Colors of widgets look weird (problem with QStyle?)

Hmm. I don't think I'm seeing this.

Which widgets look weird? Can you attach a screenshot? Or post a script example?

Rob

Hello Rob, please take a look at those screenshot and simple code example. Background color is wrong, also QTextEdit is black. And QGroupBox title is invisible:

from PySide.QtGui import *

class Grp(QGroupBox):
def __init__(self, n):
super(Grp, self).__init__()
self.setTitle(“Group_%d” % n)
vl = QVBoxLayout()
vl.addWidget(QPushButton(“Button_%d” % n))
vl.addWidget(QComboBox())
vl.addWidget(QTextEdit())
self.setLayout(vl)

def createInterface():
w = QWidget()
l = QGridLayout()
for i in range(2):
for j in range(2):
l.addWidget(Grp(i*2), i, j)
w.setLayout(l)
return w

Attachments:
2015-01-19 19-24-21 untitled.hip - Houdini Apprentice Non-Commercial.png (16.7 KB)
2015-01-19 19-22-00 untitled.hip - Houdini Apprentice Non-Commercial.png (17.1 KB)

Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
User Avatar
Staff
1255 posts
Joined: July 2005
Offline
Ah. Thanks Alexey. I've logged a bug for this (bug 66328).

Cheers,
Rob
User Avatar
Staff
585 posts
Joined: May 2014
Offline
Calling setStyleSheet in Python Panels should work as expected in tomorrow's build. Since we're using stylesheets, QFont and QPalette values are ignored automatically by Qt.

I'll take look at the QGroupBox and QTextEdit styling issues you mentioned.
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
What the best way to get styleSheet text?
At now i get it from one of QApplication top level widgets…
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
585 posts
Joined: May 2014
Offline
Getting the Houdini stylesheet from the QApplication instance should be safe in both PySide and C++ code. We don't currently have a method for directly querying Houdini's style sheet directly. The stylesheet is generated at runtime based on the current colour settings and a base stylesheet.

If you're working in C++, you can also use QT_Utils::applyWidgetStyleSheets(QWidget*) to apply the Houdini style sheet to a QWidget. Note that this will overwrite any style sheets currently set on the QWidget.
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
QApplication instance should be safe in both PySide and C++ code
QtGui.QApplication.instance().styleSheet() retrurn empty string

QT_Utils::applyWidgetStyleSheets(QWidget*)
Can`t find this method
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Staff
1255 posts
Joined: July 2005
Offline
vux
QApplication instance should be safe in both PySide and C++ code
QtGui.QApplication.instance().styleSheet() retrurn empty string

QT_Utils::applyWidgetStyleSheets(QWidget*)
Can`t find this method

Whoops for both items.

I fixed the QtGui.QApplication.instance().styleSheet() problem so that should start working in tomorrow's H14 build (14.0.221).

Also looking in the HDK we don't expose the QT_Utils class which is probably a good thing. You should be able to access the app stylesheet similarly in C++ like so:

QApplication::instance()->styleSheet()


But like the Python version this function call will start working in tomorrow's H14 build.

Cheers,
Rob
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Thanx!
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
Hello Rob,

According to journals, drag&drop was fixed, but i can't get it to work in 220 build.


from PySide.QtGui import *

class My(QWidget):
def __init__(self):
super(My, self).__init__()
self.setAcceptDrops(True)

def dropEvent(self, event):
print event
urls = event.mimeData().urls()
file = urls.toLocalFile()
event.acceptProposedAction()

def wheelEvent(self, event):
print event.delta()
event.accept()

def createInterface():
return My()


Also problem with colors from my previous post, still exists.

Thanks for your effort and quick response, you guys doing amazing job!

Alexey.
Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
User Avatar
Staff
585 posts
Joined: May 2014
Offline
Alexey,

Can you try adding the following method to your Python Panel script:
def dragEnterEvent(self, event):
event.acceptProposedAction()

That block of code was needed to make the example work on my machine. Also, which platform are you currently using? I'm working through some drag and drop bugs on OS X so if you're on the platform drag and drop may not work as expected.
User Avatar
Member
183 posts
Joined: Nov. 2008
Offline
tpetrick
Alexey,

Can you try adding the following method to your Python Panel script:
def dragEnterEvent(self, event):
event.acceptProposedAction()

That block of code was needed to make the example work on my machine. Also, which platform are you currently using? I'm working through some drag and drop bugs on OS X so if you're on the platform drag and drop may not work as expected.

Yes, it works! Although there are some problems:
1. There are drop areas in python panel, where “Drop Actions” popup occurs (occasionally)
2. How one knows what was dropped(node, parm, text)? Currently, mimeType of any drops from houdini is ‘text-plain’

I'll submit #1 as a bug.

Cheers,
Alexey.

Attachments:
2015-01-23 11-10-11 Скриншот экрана.png (60.7 KB)

Aleksei Rusev
Sr. Graphics Tools Engineer @ Nvidia
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Good fixes! I dont know how long we have to wait its form AutoD*** )))

I consider that we still need ability to find main widget from python.

I remind that at now i get it from top level widgets and test it by windowIconText() function. If it contains something then it is MainWidget
Not so elegant but it works

Anyway you give us good Qt implementation and in some cases it more robust than in Maya !!!

Thanx !!!
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Also at now i can install eventFilter to viewport widget in my tools.
But it would be good if we can catch Enter\Leave and HoverEnter\Leave events, because its good way to identify that we left out viewport widget.
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
I have bad news. In my case, linux x64 and any of H14 builds, i can`t get my custom eventFilter to work allways.

Bug submitted…


EDIT:

I saw that this BUG reproduces when i want to catch QtCore.QEvent.KeyRelease, but not with QtCore.QEvent.KeyPress

EDIT1:
I continue to consider this problem. The problem is with key events only.
It doesn`t works allways. But, for example, with QtCore.QEvent.MouseButtonPress it works well. And it doesn't matter if i installed filter to specific widget or to QApplication instance…
https://gumroad.com/alexeyvanzhula [gumroad.com]
User Avatar
Member
538 posts
Joined: Dec. 2006
Offline
Can reproduce this BUG if eventFilter class described in Shelf Tool Script section.
Works normally if i described class in external python script, for example, in file
https://gumroad.com/alexeyvanzhula [gumroad.com]
  • Quick Links