c++ - Overridding QMessageBox::paintEvent() -
i creating custom message box application. object derived qmessagebox, overriding paintevent() method in order change appearance. curiously, although not call base paintevent method in derived method, custom message box still being painted ok button default. here code:
class messagewidget : public qmessagebox { q_object public: messagewidget(qwidget* parent = 0); ~messagewidget(); void settitle(const qstring& title); const qstring& title() const; protected: void paintevent(qpaintevent* event); } messagewidget::messagewidget(qwidget* parent) : qmessagebox(parent) { setwindowflags(qt::framelesswindowhint); setautofillbackground(true); } void messagewidget::paintevent(qpaintevent* /*event*/) { qpainter painter(this); qrect boxrect = rect(); qpainterpath path; path.addroundedrect(boxrect, 15, 15); painter.fillpath(path, palette().window()); painter.drawpath(path); qrect titlerect = boxrect; int titleheight = fontmetrics().height(); titlerect.movebottom(titleheight); boxrect.movetop(titlerect.bottom()); painter.drawline(titlerect.bottomleft(), titlerect.bottomright()); painter.drawtext(titlerect, qt::alignleft, "some text"); }
how other things being painted when i'm not calling base paintevent method?
the ok button not being painted. it's child qwidget added message box. child widget painting not controlled in parent's paintevent.
Comments
Post a Comment