سؤال

I want to use a png image with transparency and custom border in Qt mainwindow background like this.


(source: shiaupload.ir)

is there any good idea?

هل كانت مفيدة؟

المحلول

You can do something like this:

this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);

Then paint the background of your window in the paint event.

Note: As pointed out by Dmitry, in Qt4 there is a bug with minimizing and restoring the window.

Another option is to use QWidget::setMask(const QBitmap & bitmap), but this could be slow if the region is complex.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top