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. Update scene
Forum Updated to NodeBB v4.3 + New Features

Update scene

Scheduled Pinned Locked Moved Solved General and Desktop
updatesceneqgraphicsview
34 Posts 3 Posters 12.3k Views 3 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.
  • M mrjj
    25 Jan 2016, 19:23

    if pos() returns 0,0 , it must mean the items is actually at 0,0.

    M Offline
    M Offline
    mandruk1331
    wrote on 25 Jan 2016, 19:40 last edited by
    #23

    @mrjj and the other ones return 0,0. The object are unique they are all parents and have no child, I want to get the positions of each object so I could move them

    Mandruk1331

    M 1 Reply Last reply 25 Jan 2016, 19:43
    0
    • M mandruk1331
      25 Jan 2016, 19:40

      @mrjj and the other ones return 0,0. The object are unique they are all parents and have no child, I want to get the positions of each object so I could move them

      M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 25 Jan 2016, 19:43 last edited by
      #24

      @mandruk1331
      Something is not right.
      Unless they are all really drawn at 0,0 then pos() should return the
      actual position.
      Did you new a QGraphicsRectItem and inserted directly in the list?

      M 1 Reply Last reply 25 Jan 2016, 19:45
      0
      • M mrjj
        25 Jan 2016, 19:43

        @mandruk1331
        Something is not right.
        Unless they are all really drawn at 0,0 then pos() should return the
        actual position.
        Did you new a QGraphicsRectItem and inserted directly in the list?

        M Offline
        M Offline
        mandruk1331
        wrote on 25 Jan 2016, 19:45 last edited by
        #25

        @mrjj yes, and in the constructor I have set theirs poistions

        Mandruk1331

        M 1 Reply Last reply 25 Jan 2016, 19:47
        0
        • M mandruk1331
          25 Jan 2016, 19:45

          @mrjj yes, and in the constructor I have set theirs poistions

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 25 Jan 2016, 19:47 last edited by
          #26

          Ok, then they should still have the pos, unless you swapped with a
          item having 0,0.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 25 Jan 2016, 19:51 last edited by
            #27

            Can I ask how any values (rects) you try to visualize?

            M 1 Reply Last reply 25 Jan 2016, 19:58
            0
            • M mrjj
              25 Jan 2016, 19:51

              Can I ask how any values (rects) you try to visualize?

              M Offline
              M Offline
              mandruk1331
              wrote on 25 Jan 2016, 19:58 last edited by
              #28

              @mrjj 10

              Mandruk1331

              M 1 Reply Last reply 25 Jan 2016, 20:04
              0
              • M mandruk1331
                25 Jan 2016, 19:58

                @mrjj 10

                M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 25 Jan 2016, 20:04 last edited by
                #29

                @mandruk1331
                ok.
                And did you write the sort also?

                M 1 Reply Last reply 25 Jan 2016, 20:30
                0
                • M mrjj
                  25 Jan 2016, 20:04

                  @mandruk1331
                  ok.
                  And did you write the sort also?

                  M Offline
                  M Offline
                  mandruk1331
                  wrote on 25 Jan 2016, 20:30 last edited by
                  #30

                  @mrjj yes
                  for( int i=0;i<random_numbers_.size()-1;i++){
                  for(int j=0;j<random_numbers_.size()-1;j++){

                         if(random_numbers_[j]>random_numbers_[j+1]){
                             count++;
                  

                  QTimer::singleShot(1000*count, [=]{ MainWindow::Shot(j);});

                          }
                      }
                  }
                  

                  Mandruk1331

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 25 Jan 2016, 20:48 last edited by
                    #31

                    ok.
                    Don't really look like bubble sort.
                    :)

                    M 1 Reply Last reply 25 Jan 2016, 21:37
                    0
                    • M mrjj
                      25 Jan 2016, 20:48

                      ok.
                      Don't really look like bubble sort.
                      :)

                      M Offline
                      M Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on 25 Jan 2016, 21:37 last edited by
                      #32

                      Hi
                      I made a half assed bubble sort visualization using
                      widget painting.

                      2 things wrong with it.
                      The actual sort should rather be able to single step but instead
                      I use a delay function to slow down drawing. (not pretty)
                      So consider it concept rather than good practice.

                      That said, its meant for inspiration for your project.

                      https://www.dropbox.com/s/ob3x0uvdtbio942/bsort.zip?dl=0

                      M 1 Reply Last reply 25 Jan 2016, 21:40
                      1
                      • M mrjj
                        25 Jan 2016, 21:37

                        Hi
                        I made a half assed bubble sort visualization using
                        widget painting.

                        2 things wrong with it.
                        The actual sort should rather be able to single step but instead
                        I use a delay function to slow down drawing. (not pretty)
                        So consider it concept rather than good practice.

                        That said, its meant for inspiration for your project.

                        https://www.dropbox.com/s/ob3x0uvdtbio942/bsort.zip?dl=0

                        M Offline
                        M Offline
                        mandruk1331
                        wrote on 25 Jan 2016, 21:40 last edited by
                        #33

                        @mrjj Thanks a lot,really:-)

                        Mandruk1331

                        1 Reply Last reply
                        1
                        • A Offline
                          A Offline
                          Asperamanca
                          wrote on 26 Jan 2016, 08:43 last edited by
                          #34

                          I know I'm late to the party, but for what it's worth:

                          1. There is rarely ever a need to manually update the GraphicsScene. It will automatically update parts whenever you move items (setPos), or change properties of ready-to-use items such as QGraphicsRectItem
                          2. If you implement your own item and your own paint method, naturally the scene cannot know which properties will affect the paint and which won't. Therefore, you just call update() on the item after you changed any properties that affect the way the item looks
                          3. If you change the boundingRect(), don't forget to call prepareGeometryChange(), otherwise you will have nasty painting effects
                          4. Re sorting: qSort, anyone?
                          1 Reply Last reply
                          0

                          32/34

                          25 Jan 2016, 21:37

                          • Login

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