Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt QRubberBand颜色不是';在Mac下没有变化_Qt - Fatal编程技术网

Qt QRubberBand颜色不是';在Mac下没有变化

Qt QRubberBand颜色不是';在Mac下没有变化,qt,Qt,此代码在Windows下以蓝色绘制QRubberBand,但在MacOs下不起作用。我想知道为什么 QRubberBand *rubberBand = new QRubberBand(QRubberBand::Rectangle, this->imageLabel); rubberBand->setGeometry(rec); QPalette palette; palette.setBrush(QPalette::Highlight, QBrush(Qt::darkBlue));

此代码在Windows下以蓝色绘制QRubberBand,但在MacOs下不起作用。我想知道为什么

QRubberBand *rubberBand = new QRubberBand(QRubberBand::Rectangle, this->imageLabel);
rubberBand->setGeometry(rec);

QPalette palette;
palette.setBrush(QPalette::Highlight, QBrush(Qt::darkBlue));
rubberBand->setPalette(palette);

我是这样解决的:

QRubberBand *rubberBand = new QRubberBand(QRubberBand::Rectangle, this->imageLabel);
rubberBand->setGeometry(rec);

QPalette palette;
QColor color(Qt::blue);
color.setAlpha(80);
palette.setBrush(QPalette::Highlight, QBrush(color));
rubberBand->setPalette(palette);
现在,在MacOS和Windows下,rubberband是相同的。

可能就是这个已知的“功能”(from):默认情况下,矩形橡皮筋(s是矩形)将使用遮罩,因此矩形的一个小边框就是所有可见的。某些样式(例如,本机Mac OS X)将更改此选项,并调用QWidget::setWindowOpacity()来生成半透明的填充选择矩形?