Solved.My logic failed me, all I had to do to was to set all the background to the original background every time the mouse entered a new item.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8b0713c0-2665-45ba-b093-158ed3767acd%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ba3b42e4-716a-4db7-a020-3803d5f922d5%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/N8eOmxHAjp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1o4zimEN3%3Dt0c2-G7yOfvRDAxDbUfikQ-nJZFEvGB8gA%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/d2c1ad93-893a-4408-8068-9eae3d2a1566%40googlegroups.com.
class PoseListView(QtGui.QListWidget):
def __init__(self, parent=None):
super(PoseListView, self).__init__(parent)
...
self.setItemDelegate(Highlighter(self))
class Highlighter(QtGui.QItemDelegate):
def paint(self, painter, opts, index):
super(Highlighter, self).paint(painter, opts, index)
if opts.state & QtGui.QStyle.State_MouseOver:
grad = QtGui.QLinearGradient(opts.rect.topLeft(), opts.rect.topRight())
grad.setColorAt(0, QtGui.QColor(0,0,255,60))
grad.setColorAt(1, QtGui.QColor(0,0,255,20))
painter.fillRect(opts.rect, QtGui.QBrush(grad))
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/940059fd-756b-471f-aa3c-3a0e6a8220fa%40googlegroups.com.
Hi Bay,
Am I understanding you correctly in that you want to have an image appear when the user hovers an item, and have another image appear when he exits? You can do something like this:
QListWidgetItem {
background-image: url(my_image.png)
}
QListWidgetItem:hover {
background-image: url(my_hover_image.png)
}
QListWidgetItem:checked:hover {
background-image: url(my_checked_hover_image.png)
}
Where “my_image” is an image path relative to where you ran the script.
I personally avoid any styling in Python and haven’t yet found a reason to since I started using Stylesheets, they rock!
@Marcus, I believe based on the example code that a different image is meant to be used dynamically for each item. That is, unless I read the example wrong.
@Bay, since you can only assign one delegate per row/column, you would need to have all of you conditions in that same delegate. Just be very mindful of what you do in a paint method. It gets called very often and you don't want to do anything that takes a lot of time otherwise it will lag. For more expensive calls or things where the value doesn't change, you can compute them once ahead of time.
I tend to use both style sheets and paint logic. Stylesheets are great for overall custom looks and behavior, but obviously they can only express logic within the ability of css. If you end up wanting to draw anything more custom, then paint logic let's you do basically thing you want. I did an example of this in my PyQt video where I made a custom gauge widget. I also use custom paint delegates for stuff like drawing special progress bars in views or different types of dynamic state indicators.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODCq%2B_a06N8rvyJ6WPaUFqO6DTsJQiivck%3Du8Yj5Pgc_w%40mail.gmail.com.
I see. I had a look at your example @Bay and I take it the widget will display an image per pose, like a pose library.
In this case, if you really want to use a QListWidget, you can subclass QListWidgetItem, append a “hover widget” and have that be transparent and highlight whenever a mouse moves over it. That way, you have the original widget showing the image, and another taking care of user feedback.
Alternatively, you can also use a QVBoxLayout and QWidget. Subclass the QWidget and hover widget and stack that within your Layout.
This way, you get of all the performance benefits, whilst still being able to control the look and feel through stylesheets. In this case, you can name your overlay widget through setObjectName and access that using the hash-tag.
To select all QWidgets with a child called “Hover”, you can do this:
QWidget #Hover {
background-color: rgba(1, 1, 1, 0);
}
QWidget #Hover:hover {
background-color: rgba(1, 1, 1, 0.3);
}
The same goes for your QListWidgetItem:
QListWidgetItem #Hover {
background-color: rgba(1, 1, 1, 0);
}
QListWidgetItem #Hover:hover {
background-color: rgba(1, 1, 1, 0.3);
}
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/N8eOmxHAjp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA05AT0Q7iHs-uO0AVtKj-K44ZnGWOJTnspxdYzPyTmd7Q%40mail.gmail.com.
Thank youGann Boon Bay
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAO52s0Ffm7R8gMRhMyq4-ZNZa-QgX5NWGtFwt%2BB7dqp70%2BRtNA%40mail.gmail.com.
Hi Justin,thank you again for taking the time to explain using QItemDelegate to me. Would it be possible for you to explain to me what you mean by " For more expensive calls or things where the value doesn't change, you can compute them once ahead of time."? just want to understand the scenario that you're speaking of.
Regarding the tutorial you speak of, I'm assuming it's the PyQT UI Tutorial on cmivfx?
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAO52s0GQuje-coyeEe0VN8FpH2z%2B5ZWAwvH8VcyP03iGr9xd3g%40mail.gmail.com.
You definitely don't want to be calling any of the begin* methods in this situation.
I think what you are looking for it the save() / restore() methods:
http://qt-project.org/doc/qt-4.8/qpainter.html#save
That would let you first call save() and then make a bunch of changes to the painter settings like pen and brush and attributes, do your painting, and then restore the painter to its previous state. Make sure to call restore() at the end of the context when you want to revert to the last settings.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/2433fc89-fcd0-41d9-905d-39186263aa55%40googlegroups.com.
QListWidgetItem:hover {
border: 4px solid green;
}
Tadaaa! :)
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1nCP_Ty%2BShg%2BpNSGZ8YyavBr-rb024pcSUCphTyu6Zvw%40mail.gmail.com.
More to the point:
QListWidgetItem:focus {
border: 1px solid white;
}
You also have outline, instead of border.
http://www.w3schools.com/css/css_outline.asp
I'm surprised you even had to call that. Normally that all should happen automatically. I wonder if you were painting outside of the rect area? If you paint larger than the rect in one situation and then not in another, you can get left over pixels not cleaned up until the surrounding areas get repainted. Sometimes if you are using a larger pen width for an outline, you have to compensate and shrink the rect.
Example:
penWidth=4
aRect=opts.rect.adjusted(2,2,-2,-2)
I have to find the doc on this but I remember it describing how the width of a pen grows from the center, which means it can start extending beyond the rect.
Solved the issue, I was looking in the wrong place.Since the border drawing is trigged by a selection, I just set the itemselectionchange signal to signal an update to refresh the list widget, cleans the residue from the QPen.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/093c1332-28ba-4898-a798-cfffafaebfbe%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/04f02ca9-69bd-43f6-bedb-d61a3be24f51%40googlegroups.com.
You shouldn't be using both a delegate and the cell widget feature. They both aren't meant to work together, as like you said, the widget is drawn on top of whatever is being painted in the cell. Either you use a delegate with a QAbstractItemView or subclasses, or you are using the special feature of the high level QListWidget that let's you set widgets into it. So you should pick one or the other.
If you are going with the delegate, you have full control with the paint method to draw your text yourself at the position that makes sense for the rest of your custom look.
If you go with the compound widget in each item, I am sure you already can get that looking the way you want.
You may never hit this problem if you aren't showing enough items, but you are more likely to encounter performance issues with the set widget approach first, than the delegate, since each widget has its own events to maintain. Just a difference between them if you care to know why one would choose either approach.
Hi Justin,sorry to have to bother you again. A problem I'm having with using the qlistwidgetitem is that the text tend to get obscured by the selection frame drawn (since the text is set to align (QtCore.Qt.AlignBottom | QtCore.Qt.AlignHCenter)). Now, it was possible to give a more customized look by creating a Qwidget with 2 labels to hold the thumbnails and text and using setItemWidget but it seems that the QStyledItemDelegate only draws over the QListWidgetItem but not the custom Widget set into it (Feels like the custom widget is set atop of the QListWIdgetItem). I could use setstylesheet to individually control the behavior of the 2 labels in the custom widget together with the itemdelegate but it seems rather inefficient to do it that way. I was wondering if there might be a flag or command that I'm missing, thanks again for any assistance rendered :)
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/3cef5d44-a3e5-4dd1-89ce-a587b096a658%40googlegroups.com.
Hi Justin,sorry to keep bothering you. It seems like the solution is like you say to just use QStyledItemDelegate to do it. The problem is I haven't been able to understand how to connect the widget item with the item delegate. For example, trying to connect the text of the item with a variable in the item delegate. Would appreciate any assistance rendered : )
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/914f9016-8ff9-486f-94c2-43ccb58b3297%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/N8eOmxHAjp4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3BZsX3jLfg7_iD4XzNtvx6Z_XapYimv9fr766_k_r__g%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAO52s0EfxSv_AtRw4hmU6jZXRc26dBfOHzVqJ2KNz_16fWQJWQ%40mail.gmail.com.