PDA

View Full Version : Drawing a Table Widget like styled frame around a simple QWidget



ghorwin
8th July 2009, 11:01
Hi there,

I'm trying to draw a frame around my custom widget, so that the widget looks exactly like an empty table widget. I have overloaded the paintEvent and draw my widget's contents, but I can't get the styled frame drawing to work.

I tried



void DiagramWidget::paintEvent ( QPaintEvent * event ) {
QStylePainter p(this);

// my own drawing code
DiagramPainter diagramPainter;
diagramPainter.paint(&p, QRect(0,0,width(), height()), m_results, m_inputData);

// here I want to write the frame/panel border, but that won't work
QStyleOptionFrameV2 panel;
panel.initFrom(this);
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &panel, &p, this);
}



In any case, to get a nice looking interface I want to mimic the appearance of a QTableWidget that is placed side by side to the diagram. How can I do this?

Thanks,
Andreas