Results 1 to 8 of 8

Thread: mapToGlobal/mapFromGlobal isn't working properly

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: mapToGlobal/mapFromGlobal isn't working properly

    Quote Originally Posted by wysota View Post
    So it is managed by a layout which might explain why your own geometry management fails. If you wish to do your own moving/resizing, you can't use layouts at the same time.
    That makes sense. However, as a quick test I changed the code that creates the popup so that it doesn't have a parent. Shouldn't that mean that it's position is no longer affected by the main window's layout? When I did this, I didn't see any change in behavior...

    Quote Originally Posted by wysota View Post
    I suggest you forget about docks for now and implement your solution as working for any possible widget. When you have that done you can adjust the code to work for your specific case. mapToGlobal() and mapFromGlobal() both work fine so if they fail in your case then it has to be caused by your own code. Move the popup code out of your specific use-case, make it work as a standalone solution and then integrate it back to your main project.
    I will look into doing this

  2. #2
    Join Date
    Apr 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: mapToGlobal/mapFromGlobal isn't working properly

    Problem has been "solved". It is not a layout issue as was suspected. While performing different tests I noticed a few things that led me to the "fix":
    • The geometry before and after the move was different
    • This caused the final x and y coordinates to be off by a certain amount
    • I noticed that the amount the coordinates were off also happened to coincide directly with the geometry changing (e.g. If the x coordinate was off by 4 pixels from what was expected, the width of the final geometry would change by 4 pixels. The same was true for the y coordinates).


    These things led me to believe that I was calculating my positions based on bad geometry, which would in turn cause my positions to be incorrect... I tried calling updateGeometry() on the popup widget but that didn't have any effect.

    As a test, I tried calling move on the popup widget before calculating my offsets. This turned out to work! So, for some reason that I can't figure out, the geometry is not correct until after the first time the widget has been moved.

    I admit this is a bit hackish but I get the results I want. Everything lines up perfectly now. I am open to other solutions if anyone has any to offer. Until then this is how we are "fixing" the problem.

Similar Threads

  1. Replies: 1
    Last Post: 23rd February 2012, 12:13
  2. QToolbar expanding sizePolicy not working properly
    By sfcheng77 in forum Qt Programming
    Replies: 2
    Last Post: 23rd February 2011, 00:50
  3. memcpy not working properly
    By sattu in forum Qt Programming
    Replies: 3
    Last Post: 27th October 2010, 00:33
  4. ScrollZoomer not working properly..
    By Raghaw in forum Qwt
    Replies: 1
    Last Post: 30th October 2009, 07:51
  5. Replies: 1
    Last Post: 2nd June 2006, 00:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.