PDA

View Full Version : Custom QFrame



fruzzo
19th October 2009, 13:41
Hi,
I want create a new widget like a QFrame but with a customized frame, something like this one:
http://www.verdeblu.gr/italian/top_right_frame_np.jpg

My idea is to inherit from QWidget, insert a QFrame in its vertical layout and overide the QWidget::printEvent and draw my custom frame around the QFrame but I've some problems with the the right size of the QFrame.
Is there a better way to do my task?

Obsviously, than I want to be enabled to insert other widgets inside the white space like in a standard QFrame...

high_flyer
19th October 2009, 15:00
Why not derive QFrame it self?
It is of course possible the way you are doing it too.
But other then that, that is the way to go, yes.

fruzzo
19th October 2009, 17:41
Why not derive QFrame it self?
It is of course possible the way you are doing it too.
But other then that, that is the way to go, yes.

Ok...but if I directly inherit from QFrame than how I can customize the frame border?

high_flyer
19th October 2009, 20:20
The same way you where doing it with subclassing QWidget - by overloading the paintEvent().

fruzzo
20th October 2009, 13:12
The same way you where doing it with subclassing QWidget - by overloading the paintEvent().

ok I supose that but...in the paintEvent, how can I draw around the contents view? What is the right bounding of the contents? I try to use the contentsRect but then drawing is not so fine...later I try to post a portion of code.

high_flyer
20th October 2009, 14:49
look at QWidget::setContentsMargins ( )