[Qt-interest] Dynamic painting in a QMdiArea

Pascal Francq pfrancq at ulb.ac.be
Tue Jan 13 11:56:45 CET 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,
I have develop an KDE application with a main window (inheriting 
'KXmlGuiWindow') containing one 'QMdiArea' widget. When multiple windows are 
opened, I want to give the user the opportunity too choose two windows. In 
practice, when clicking on a button in the toolbar, the user clicks on one 
window, holds the mouse button, move to the second window, and release the 
button. This works.
During the move, I want to draw a (red) line from the first window to the 
actual position of the mouse. The solution I use actually is to catch the 
movement of the mouse in the main KDE window, drawing a line in a QPixmap and 
calling 'updated()'. In the 'paintEvent' method of this KDE window I call the 
'render' method of the 'QMdiArea' widget:

	void KInfoMng::mouseMoveEvent(QMouseEvent* event)
	{
		if(Press)
		{
			Pixmap=new QPixmap(Main->Desktop->size());
			QPainter Painter(Pixmap);
			Painter.setPen(Qt::red);
			Painter.drawLine(firstx,firsty,event->x(),event->y());
			update();
		}
	}

	void KInfoMng::paintEvent ( QPaintEvent * event )
	{
		if(Pixmap)
		{
			Main->Desktop->render(Pixmap);  // The line was draw in Pixmap
			Pixmap=0;
		}
		else
			KXmlGuiWindow::paintEvent(event);
	}

But the QMdiArea does not show anything. Does this means that I have to create 
a class inheriting from QMdiArea and to overwrite the 'paintEvent' method 
there?

Thanks.
- -- 

Pascal Francq

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAklsc20ACgkQoiZc4N+hp30nTgCgrNSSVvBCs+Jv0IcySLV3HrgP
PWEAnA7nHwyxUTwI0oLS6c4Zw60ileSe
=6GOe
-----END PGP SIGNATURE-----



More information about the Qt-interest-old mailing list