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 to scale down QGraphicsItem in Qt?
Qt 6.11 is out! See what's new in the release blog

How to scale down QGraphicsItem in Qt?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 899 Views 2 Watching
  • 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.
  • T Offline
    T Offline
    tushu
    wrote on last edited by tushu
    #1

    I have a QGraphicsItem made up of QGraphicsPathItem (polyline) and QGraphicsEllipseItem (an Arc )
    Through co-ordinates of Line and an Arc I have drawn QGraphicsItem ( XNOR gate ) But the problem is, it is quite bigger.
    I want that it should get fit in a rectangle. But I do not want to resize it manually.

    resize.png

    The above figure is showing the current scenario. I want to scale down XNOR gate such that it's input line should match to the a0 and a1 rectangle and it's output should get match to the o rectangle. Currently I have hidden whole rectnagle and showing only input , output (small) rectangle.

    I am reading co-ordinates of XNOR gate and storing them in a object. And when I am drawing those on a scene I want to resize them.
    How to do that ? Can anyone help me ?

    T 1 Reply Last reply
    0
    • T tushu

      I have a QGraphicsItem made up of QGraphicsPathItem (polyline) and QGraphicsEllipseItem (an Arc )
      Through co-ordinates of Line and an Arc I have drawn QGraphicsItem ( XNOR gate ) But the problem is, it is quite bigger.
      I want that it should get fit in a rectangle. But I do not want to resize it manually.

      resize.png

      The above figure is showing the current scenario. I want to scale down XNOR gate such that it's input line should match to the a0 and a1 rectangle and it's output should get match to the o rectangle. Currently I have hidden whole rectnagle and showing only input , output (small) rectangle.

      I am reading co-ordinates of XNOR gate and storing them in a object. And when I am drawing those on a scene I want to resize them.
      How to do that ? Can anyone help me ?

      T Offline
      T Offline
      tushu
      wrote on last edited by
      #2

      @wysota @d_stranz @SGaist
      Can you look into this question ?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        QGraphicsItem::setScale comes to mind.

        On an unrelated note, please stop @ people like you are doing in your latest questions. It's rude and disrespectful for other forum members. This a voluntary driven forum. People come here when they have time and the desire to answer questions not on your request.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        T 1 Reply Last reply
        2
        • SGaistS SGaist

          Hi,

          QGraphicsItem::setScale comes to mind.

          On an unrelated note, please stop @ people like you are doing in your latest questions. It's rude and disrespectful for other forum members. This a voluntary driven forum. People come here when they have time and the desire to answer questions not on your request.

          T Offline
          T Offline
          tushu
          wrote on last edited by
          #4

          @SGaist My intention is not to disrespecting anyone. But if you feel so, sorry for that. From next time own wards I will keep this in mind. Thank you.

          I do not have a single QGraphicsItem to use setScale(). My structure is something like this.

          struct mySymbols
          {
             vector<LINES> lines;      
             vector<ARCS> arcs;
          };           
          struct LINES
          {
            tuple<int,int,int,int> lines_
          };
          struct ARCS
          {
            tuple<int,int,int,int,int,int> arc_;
          };
          std::map<std::string, mySymbols> allSymbols
          

          So in a map, there is a object of mySymbols through which I am trying to access all the lines, arc etc.
          So not understanding how to use setScale() here.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You are creating graphics items out of these structures, no ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            T 1 Reply Last reply
            0
            • SGaistS SGaist

              You are creating graphics items out of these structures, no ?

              T Offline
              T Offline
              tushu
              wrote on last edited by
              #6

              @SGaist Yes.
              I am reading co-ordinates and storing them in this structure.
              For arc , I am reading 6 co-ordinates from file and storing them in a struct object and then giving it to Qt API.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Don't you have a scale factor provided already when you build these structures ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                T 1 Reply Last reply
                0
                • SGaistS SGaist

                  Don't you have a scale factor provided already when you build these structures ?

                  T Offline
                  T Offline
                  tushu
                  wrote on last edited by
                  #8

                  @SGaist Yes. They have provided. But though I used those factor, it is not perfectly fitting. I have to bring that symbol down. ( by changing y co-ordinates of lines ). So I was told that, let Qt do this scale up and down.
                  That's why I am asking, is there any way that Qt will scale down QGraphicsItem before drawing on scene ?

                  M 1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    One thing I am wondering is how what values you have for the letter parts that make such a change of size with regard to the gate itself.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • T tushu

                      @SGaist Yes. They have provided. But though I used those factor, it is not perfectly fitting. I have to bring that symbol down. ( by changing y co-ordinates of lines ). So I was told that, let Qt do this scale up and down.
                      That's why I am asking, is there any way that Qt will scale down QGraphicsItem before drawing on scene ?

                      M Offline
                      M Offline
                      mchinand
                      wrote on last edited by
                      #10

                      @tushu said in How to scale down QGraphicsItem in Qt?:

                      That's why I am asking, is there any way that Qt will scale down QGraphicsItem before drawing on scene

                      @SGaist, already mentioned this, but it seems like setScale() will do what you want.

                      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