Search code examples
c++qtqt5qwidgetqdialog

How to draw a caret/arrow bottom of a QDialog on qt5


I want to draw a caret / arrow top or bottom of a qt window. I cannot find any document regarding to this.

How can I accomplish this task with qt5? I've searched all possible words but can't find anything.

Can this be applied to QDialog or qml needed? My first choice is QDialog since I have a webengine and other qwidgets already in a QDialog.

I'm using C++.

Here is what I mean: sample


Solution

  • Most window-managers don't support non-rectangular windows directly, which means that if you want to do something like this you'll need to fake it by making the window large enough to include both its normal content and the desired caret-shape inside the window-area, and making the window transparent at the top.

    To do that, call setAttribute(Qt::WA_TranslucentBackground) and setAttribute(Qt::WA_FramelessWindowHint) on your dialog, and override paintEvent(QPaintEvent *) to paint the dialog's background only for the parts of the dialog you want to be non-transparent.