1
QRubberBand
を使用して長方形を描画しようとしています。私は矩形の境界線を不透明に、内側を透明にする必要があります。しかし、私は境界線を透明にし、その塗りつぶしを不透明にして、それ以外の方法でしかできません。ここで私は別の方法として、透明なQRubberbandを取得できません
class roiFrame : public QRubberBand
{
public:
roiFrame(Shape s, QWidget * p = 0):QRubberBand(s, p){}
~roiFrame(){}
protected:
void paintEvent(QPaintEvent *pe)
{
Q_UNUSED(pe);
QStyleOptionRubberBand opt;
QStylePainter painter(this);
painter.setOpacity(0.8); // from aamer4yu
opt.initFrom(this);
// opt.opcatiy = false; //This one also makes the border to be transparent .
painter.drawControl(QStyle::CE_FocusFrame, opt);
}
};
を使用していたコードが、私はQPainter::drawRect
を使用して四角形を描画しようとしている:
myWindow::myWindow(QWidget *parent): QFrame(parent)
{
ui.setupUi(this);
}
myWindow::~myWindow()
{
}
void myWindow::mouseReleaseEvent(QMouseEvent * event)
{
releaseX = event->x();
releaseY = event->y();
}
void myWindow::mousePressEvent(QMouseEvent * event)
{
pressX = event->x();
pressY = event->y();
}
void myWindow::paintEvent(QPaintEvent *event)
{
QFrame::paintEvent(event);
QRectF rectangle(pressX,pressY,releaseX,releaseY);
QPainter painter(this);
painter.setOpacity(0.8);
painter.drawRect(rectangle);
painter.end();
}
デフォルトの 'QRubberBand :: paintEvent'の問題は何ですか?なぜ、 'drawControl'の第一引数として' QStyle :: CE_RubberBand'を使わないのですか? – m7913d
デフォルトのpaintEventを使用して透過矩形を取得できないため、変更しました。 QStyle :: CE_RubberBandも仕事をしていなかった。 マウスプレスイベントに基づいて、ビデオに長方形を描画しようとしています。 drawRect関数も仕事をしていませんでした。 – Som
'drawRect'で試したことを追加できますか?あなたは非常に具体的な結果を望むので、この低レベルの関数を使用することは私にとって適切なようです。 – m7913d