Aliasing in Qt Items? - qgraphicsview

How come this happens to my QPixmap painted in a QGraphicsView?
It has 0.8 opacity added by code.
It´s a PNG image. The original looks like this:
I see this kind of strange flickering that stays the same depending on the height of the QMainWindow. When i resize it, some of the pixmaps get disorted.

Related

Fit minimal size of a QDockPanel after QLabel content update

I have a QDockWidget with a QGroupBox as the top widget, with QVBoxLayout applied. This contains a QChartView and a QLabel.
The QLabel contains a text composed of several lines of different length.
First, I would like to have the QChartView the same width and height as the QLabel.
Second, as the content of the QLabel is updated by setText(...) in a Slot method, its content changes in height and width. So I would like to update the width and height of the QChartView above it.
For the moment, I only achieved to grow the entire DockPanel to accomodate longer and wider QLabel content, but not to shrink back when this content is narrower and less wide...
I did play with a lot of things, without real success (here a snippet of the Slot method that updates the QLabel content...):
self.fkChartView.hide()
self.pPDetailsLabel.hide()
self.pPDetailsLabel.parent().hide()
self.pPDetailsLabel.setText(self.canvas.grayScottModel.getPearsonPatternDescription(specie=type))
self.pPDetailsLabel.updateGeometry()
self.pPDetailsLabel.parent().updateGeometry()
self.pPDetailsLabel.parent().update()
self.pPDetailsDock.updateGeometry()
self.pPDetailsDock.update()
self.pPDetailsLabel.show()
self.pPDetailsLabel.parent().show()
# print(self.pPDetailsLabel.sizeHint())
self.fkChartView.setMinimumHeight(self.pPDetailsLabel.size().width())
self.fkChartView.setMaximumHeight(self.pPDetailsLabel.size().width())
self.fkChartView.setMinimumWidth(self.pPDetailsLabel.size().width())
self.fkChartView.setMaximumWidth(self.pPDetailsLabel.size().width())
self.fkChartView.updateGeometry()
self.fkChartView.show()
self.fkChartView.updateGeometry()
self.fkChartView.update()
I tried to hide the widgets, so they forget their sizes and/or sizeHint (not sure).
I tried a few updateGeometry() and update() too, but it does not seem to help.
An idea, anyone?
I had it working as intended in the end by doing this in the slot method that updates the content of the QLabel:
self.fkChartView.hide()
self.pPDetailsLabel.setText(self.canvas.grayScottModel.getPearsonPatternDescription(specie=type))
self.pPDetailsLabel.adjustSize()
self.pPDetailsLabel.parent().adjustSize()
# Sets the dimensions of the chart folowing the label width
self.fkChartView.setMinimumHeight(self.pPDetailsLabel.size().width())
self.fkChartView.setMaximumHeight(self.pPDetailsLabel.size().width())
self.fkChartView.setMinimumWidth(self.pPDetailsLabel.size().width())
self.fkChartView.setMaximumWidth(self.pPDetailsLabel.size().width())
self.fkChartView.adjustSize()
self.fkChartView.show()
self.pPDetailsDock.adjustSize()
So I first hide the QChartView, so its dimensions do not interfere,
then all the magic happens thanks to the adjustSize() call. I do this on the QLabel after its content has been updated,
then on its parent (the top QGroupBox in my QDockWidget).
The QChartView still hidden, I force its dimensions,
then show it and
finally adjust the size of the QDockWidget.
It does precisely what I want:
if text is broader, the chart expands but stays square,
if text is narrower, chart shrinks, but stays square.
Total height of the dock adjusts also to fit, without staying the longer and longer it had to be to accomodate for a big former QLabel content.

Move Raphael path with png fill image, without breaking image in IE or moving image relative to element?

There are three basic ways to move a path in Raphael.
If that path has a fill image that has PNG transparency, and you need IE8 (VML), all three are flawed.
JSBin demo
If you use a simple transform...
path1.animate({transform: 't20,100'},1000);
...then in IE8, the png transparency in the fill breaks and translucent pixels turn black. Edges become pixelated and ugly, and depending on the image you might get a scuffy black outline around the translucent edge of the image. Not good, and there doesn't seem to be any reliable way to fix this after the event.
Sometimes, inconsistently, the background image also doesn't stay relative to the element (more on that below).
If you animate the path attribute, for example like this:
path2.animate({path: Raphael.transformPath( path2.attr('path'), 't100,20') },1000);
...IE8 doesn't wreck the image background. However, the fix for making background images relative to the element not the paper does not work with this method (and various ways I've tried to bodge it using improved background image offset with an additional "M-20,-20" element don't seem to work), and I can't find any way to make that work either.
Also, just having lots of transformations on the go can break the delicate IE8 bug the background image fix depends on in VML mode, causing the background to move. This seems to be inconsistent - with the JSBin above, in IE8, sometimes they all move, sometimes only the top one moves.
If you use translate...
path3.translate(42,42);
...the results are the same as transform (presumably both use the same translate functions).
With Raphael image elements, it's possible to fix this broken alpha by applying opacity with the transform in an attr or animate call. This doesn't work with path fills. Also, turning off the fill and resetting it from the original URL string doesn't remove the broken alpha contamination. You can see this in this demo.
So, I'm looking for a way to move a Raphael path that has a background image that has PNG transparency that a) keeps the image relative to the element, consistently and b) doesn't wreck the PNG transparency in IE8 by turning partial transparency into pixelated black.
Similar problems occur with any form of transformation - such as scale, rotate etc.
I can't find any good answer to this: the closest I've found is an ugly but functional workaround for IE8 transform (wrapped in if(Raphael.type=='VML')s so you don't spoil things for real browsers):
Before doing any transform to anything that has an alpha transparency PNG / pattern fill, remove the pattern fill (path.attr({fill:'none'});), storing the fill setting like path.data('fill',path.attr('fill'));
After the transform, asynchronously (e.g. wrapped in setTimeout(function(){ })) re-apply the fill e.g. path.attr({fill: path.data('fill')});
The crucial thing seems to be: the fill must not be applied when the transform occurs, else it'll be ruined forever, even if you remove and re-apply it. Be careful with the timing on this - it mustn't be possible for the fill to re-apply before the transform completes (e.g. watch out for race conditions with animations or other async processes).
If you're animating a transform, your options seem to be to either:
Clear the fill before the animation, just accept that there will be no fill while the animation takes place, and re-set in a callback after the animation completes
Implement your own animation handler than removes and re-applies the fill before and after every frame (this, of course, risks being a performance nightmare).

gtk3 transparent menu's

Is it possible in gtk3 to create a menu that is transparent? The underling window would use an image as it's background.
I can use a color for the window background but not a image.
I attempted to do what you said using an example from the gdk2 reference by adding a background image first and then porting it to gtk3. I'm no expert at gtk at all, but I did make it somehow compile:
http://pastebin.com/0XwUW5k3 (note that there has to be a "background.png" in the same folder)
The transparent dark rectangle holding the widgets is most likely the box; I tried settings its background color to full transparency as well, but it didn't work, and you'd probably have to do the composing/drawing of it yourself if you wanted it to be completely transparent, but that's not something I'd suggest because it seems too complex..
Also, you might want to create a background image with an already fitting resolution for the window, then you could skip the scaling part.
The scale function originally comes from this mailling-list thread

Animating UIButton alpha with a PNG background: why does the animation get bright white as it transitions from alpha = 0 to alpha = 1?

This is something that is stumping me; I have a simple UIButton with the following PNG as it's background:
I'm using an iOS 4 block animation, and all I'm doing is animating it's alpha property from 0.0 to 1.0. However, while the animation is in progress, the UIButton gets bright white, before finally settling to look like the above image when the property reaches 1.0.
I'm pretty stumped - if, for example, I open that image in Paint.NET and slide the image's opacity from 0 to 255, I see a nice fade-in effect - which is exactly what I'm going for. But when I animate an opacity change in iOS, the button gets bright white during the middle part of the animation.
If I change the animation's duration to something extended, like 5 seconds, the effect is even more prominent. Any ideas?
Edit: I am using Xcode 4.1, and running iOS 4.3.3 (first gen iPad).
It turns out, after much consideration, that the issue was my UIButton was a Round Rect button; the type needed to be changed to Custom. Even though the background images I set for my button worked when the type was Round Rect, applying an alpha animation to the button still caused the default white Round Rect style to appear for the duration of the animation. That is what my eyes interpreted as "bright white" during the animation - it had nothing to do with my PNG background, and everything to do with the underlying type of the button I was using.
Problem solved. Moral of the story? Change your UIButton type to Custom if you're going to animate the button while using your own background images.

Round Rect Button behavior when using a flipview controller

Hia.
I am using some round rect buttons with own images for their states. Each time am displaying a different view for some stuff, the buttons become white and my images are fading in briefly later.
The problem occurs only with the UIModalTransitionStyleCrossDissolve animation.
The other 3, UIModalTransitionStyleCoverVertical, UIModalTransitionStyleFlipHorizontal and UIModalTransitionStylePartialCurl, don't show this effect.
The effect would be ok, ok if the starting color would be black. I didn't find any way to change that color in IB. Where does it come from? Any idea?
Tried to set the background over the inherited properties of UIImage, but he simply ignored it. Switching the Round rect button to a custom one solved it. Leaves the question what to do if I want a round rect. A black background image didn't help. He seems to use the background color to fade.

Resources