Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I restrict the display area of a widget, apart from setting its parent?
Forum Updated to NodeBB v4.3 + New Features

How can I restrict the display area of a widget, apart from setting its parent?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 399 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Quiccz
    wrote on last edited by Quiccz
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • Q Quiccz

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Quiccz If everything else is transparent why don't you simply show a widget with the size you need?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Q 1 Reply Last reply
      0
      • jsulmJ jsulm

        @Quiccz If everything else is transparent why don't you simply show a widget with the size you need?

        Q Offline
        Q Offline
        Quiccz
        wrote on last edited by
        #3

        @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.

        jsulmJ 1 Reply Last reply
        0
        • Q Quiccz

          @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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Q 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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?

            Q Offline
            Q Offline
            Quiccz
            wrote on last edited by Quiccz
            #5

            @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();
            }
            
            
            jsulmJ 1 Reply Last reply
            0
            • Q Quiccz

              @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();
              }
              
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              Q 1 Reply Last reply
              0
              • jsulmJ jsulm

                @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?

                Q Offline
                Q Offline
                Quiccz
                wrote on last edited by
                #7

                @jsulm yes,My widget can be an image, and I am moving the image from the right side to the left side within the specified area. This is a common animation.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved