How can I restrict the display area of a widget, apart from setting its parent?
-
I want my widget to display only the absolute region (0, 0, 7680, 4320), with the remaining parts being transparent.
I tryed setMask, but it is relative position. I want absolute position.
I dont want to create a widget with size (7680, 4320) as parent. it is too large. -
I want my widget to display only the absolute region (0, 0, 7680, 4320), with the remaining parts being transparent.
I tryed setMask, but it is relative position. I want absolute position.
I dont want to create a widget with size (7680, 4320) as parent. it is too large. -
@Quiccz If everything else is transparent why don't you simply show a widget with the size you need?
@jsulm If my screen is 16k, and I want to play something only in the top-left 8k, adding an animation from right to left may cause the animation's start and end to exceed the 8k display area. Therefore, I need to constrain it to only be visible within the 8k range, with the exceeding parts being transparent.
-
@jsulm If my screen is 16k, and I want to play something only in the top-left 8k, adding an animation from right to left may cause the animation's start and end to exceed the 8k display area. Therefore, I need to constrain it to only be visible within the 8k range, with the exceeding parts being transparent.
-
@Quiccz I still don't understand why you don't simply restrict the size of your application? Or is your application in full screen mode?
@jsulm
Here is my demo code. When animation start, widget will show at region (0,1920, 100, 100). Which is out of range(0, 0, 1920, 1080).
May be my question should be How can I limit the display area of my application?#include <QWidget> #include <QPainter> #include <QRegion> #include <QApplication> #include <QPropertyAnimation> int main(int argc, char* argv[]) { QApplication a(argc, argv); auto screen_region = QRegion(0, 0, 3840, 2160); auto show_region = QRegion(0, 0, 1920, 1080); QWidget widget; widget.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); widget.setFixedSize(100, 100); QPropertyAnimation* animation = new QPropertyAnimation(&widget, "pos"); animation->setDuration(10000); animation->setStartValue(QPoint(1920, 0)); animation->setEndValue(QPoint(0,0)); widget.show(); animation->start(); return a.exec(); }
-
@jsulm
Here is my demo code. When animation start, widget will show at region (0,1920, 100, 100). Which is out of range(0, 0, 1920, 1080).
May be my question should be How can I limit the display area of my application?#include <QWidget> #include <QPainter> #include <QRegion> #include <QApplication> #include <QPropertyAnimation> int main(int argc, char* argv[]) { QApplication a(argc, argv); auto screen_region = QRegion(0, 0, 3840, 2160); auto show_region = QRegion(0, 0, 1920, 1080); QWidget widget; widget.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus); widget.setFixedSize(100, 100); QPropertyAnimation* animation = new QPropertyAnimation(&widget, "pos"); animation->setDuration(10000); animation->setStartValue(QPoint(1920, 0)); animation->setEndValue(QPoint(0,0)); widget.show(); animation->start(); return a.exec(); }
@Quiccz said in How can I restrict the display area of a widget, apart from setting its parent?:
animation->setStartValue(QPoint(1920, 0));
animation->setEndValue(QPoint(0,0));You set as start value fox x 1920 and end value 0 - is this really what you want to do?
-
@Quiccz said in How can I restrict the display area of a widget, apart from setting its parent?:
animation->setStartValue(QPoint(1920, 0));
animation->setEndValue(QPoint(0,0));You set as start value fox x 1920 and end value 0 - is this really what you want to do?