QPixmap.scaledToWidth macht Probleme

Alles rund um die Programmierung mit Qt
Antworten
PhilipLB
Beiträge: 13
Registriert: 14. September 2007 01:49

QPixmap.scaledToWidth macht Probleme

Beitrag von PhilipLB »

Hi,
die Funktion QPixmap.scaleToWidth macht hier Probleme. Und zwar wird einfach ein oberer Teil des Bildes aufgehellt?!
http://stud.fh-wedel.de/~minf8180/prob.png
zeigt das Problem.
Ziel war, das Bild halt Bildschirmfüllend anzuzeigen.
Laden und skalieren tu ich das so:

Code: Alles auswählen

	pixmap.load("pictures/4.JPG");
	if (pixmap.width() > pixmap.height()) {
		pixmap = pixmap.scaledToWidth(width(), Qt::SmoothTransformation);
		xOff = 0;
		yOff = (height() - pixmap.height()) / 2;
	} else {
		pixmap = pixmap.scaledToHeight(height(), Qt::SmoothTransformation);
		xOff = (width() - pixmap.width()) / 2;
		yOff = 0;
	}
Anzeigen:

Code: Alles auswählen

void GLWidget::paintGL() {
	QPainter painter(this);
	painter.drawPixmap(xOff, yOff, pixmap);
}
GLWidget ist abgeleitet von QGLWidget.
PhilipLB
Beiträge: 13
Registriert: 14. September 2007 01:49

Beitrag von PhilipLB »

Leite ich hingegen die Klasse nur von QWidget ab, funktioniet das Resizen wunderbar? Seltsam.
Antworten