Seite 1 von 1

[Gelöst] Transparente Analoguhr (jedoch schwarz Oo)

Verfasst: 24. Mai 2012 15:27
von 'Prest1ge.
Hallo Community. :)

Ich mache gerade meine ersten "Gehversuche" in Sachen programmierung und Qt,
und wollte eine Analoguhr mit Grafiken coden.

Ja, ich habe bereits das "analogclock example" aus der Qt-Doc gefunden,
und auch jede menge gegooglt doch leider erfolglos.

Und zwar hab ich es soweit auch schon geschafft mein "transparentes"
Ziffernblatt als QPixmap in ein QLabel zu laden.
(Am Ende soll alles mal transparent werden).

Auch der große Zeiger war "eigendlich" nach langem googeln kein Problem mehr.

Doch siehe da... jetzt ist alles schwarz und hat Grafikfehler. :shock:

Da ich euch hier nicht einfach einen Batzen code posten möchte,
sondern viel lieber verstehen würde warum das so entsteht poste
ich hier nur ein Snippet und einen Screenshot und lebe in der Hoffnung
ihr könnt mir erklären was da schief gelaufen ist. :)

Code: Alles auswählen

analogclock::analogclock()
{
	resize (262, 262);
	setWindowFlags(Qt::FramelessWindowHint);
	setAttribute(Qt::WA_NoSystemBackground, true);
	setAttribute(Qt::WA_TranslucentBackground, true);


	QLabel *ring_ = new QLabel (this);
	ring_ -> setPixmap (QPixmap ("ring.png"));


	QPixmap bigArrow ("bigArrow.png");
	QLabel *bigArrow_ = new QLabel (this);




	QPixmap rotatedPixmap (262, 262);
	QPainter p (&rotatedPixmap);

	QSize size = bigArrow.size();

	p.translate (size.height()/2, size.width()/2);
	p.rotate (90);
	p.translate (-size.height()/2,-size.height()/2);



	p.drawPixmap (0, 0, bigArrow);
	p.end();

	bigArrow = rotatedPixmap;

	bigArrow_ -> setPixmap (bigArrow);
}
Und hier das Malör...
screen_black.jpg
screen_black.jpg (8.44 KiB) 2062 mal betrachtet

Re: Transparente Analoguhr (jedoch schwarz Oo)

Verfasst: 24. Mai 2012 17:02
von Christian81
Doku hat geschrieben: QPixmap::QPixmap ( int width, int height )
Constructs a pixmap with the given width and height. If either width or height is zero, a null pixmap is constructed.
Warning: This will create a QPixmap with uninitialized data. Call fill() to fill the pixmap with an appropriate color before drawing onto it with QPainter.

Re: Transparente Analoguhr (jedoch schwarz Oo)

Verfasst: 25. Mai 2012 10:21
von 'Prest1ge.
Besten Dank, hat geholfen. :D