Re: [Interest] Glueing widgets together

2013-06-29 Thread Sensei
Thanks Tony, that is quite the same code for me. The only difference is
that my follower isn't a child of the widget that must be followed.

It might be a platform issue as suggested: I'm on a Mac...

On Saturday, June 29, 2013, Tony Rietwyk wrote:

  Sent: Friday, 28 June 2013 10:48 PM
 
  On 6/28/13 10:54 AM, Tony Rietwyk wrote:
   Hi Sensei,
  
   I have a master dialog with a slave dialog attached to one border.
   This was done using eventFilter in the slave to listen to the master
   Move and Resize events - not MouseMove.  It's only 10 lines of code,
   works well and there is no jerkiness.  It put the code in the slave,
   since it can be attached to many different dialogs in my app.
  
   The same code should work for peer dialogs - but you must be careful
   to prevent recursion by settings flags in the other dialog before
   moving it so it doesn't try to move the first one.  The recursion
   could cause the delays and high CPU usage.
  
   Can you show the code that isn't working?
 
  Sure!
 
  My code is as follows. It works, in the sense that, as I said, the
 follower
  moves to the right position. However, I can move the main window and the
  follower, visibly after a while, pops out where it should be. It's a very
  annoying visual glitch.
 
  I've tried two codes, one with overriding the event, one with a filter.
 
  =
  // The follower
  void SubContainer::followActivated(QMoveEvent *event) {
   qWarning( MOVE IT!);
 
   // Move the follower where the options_ button is
   QPoint local  = options_-pos();
   QPoint global = mapToGlobal(local);
 
   global.setX(global.x() + 0*options_-width());
   global.setY(global.y() + options_-height());
 
   qWarning(show on (%d, %d) (%d, %d), local.x(), local.y(),
 global.x(),
  global.y());
 
   follower_-move(global);
  }
 
 
 
  // Move event handler
  void MainWindow::moveEvent(QMoveEvent *event) {
   qWarning(I LIKE TO MOVE IT);
   container_-getSubContainer()-followActivated(event);
  }
  =
 
 
 
  I've tried also (of course not at the same time as the above code) to
 install an
  event filter, however, and the results are the same:
 
 
  =
  // Event filtering
  bool SubContainer::eventFilter(QObject *object, QEvent *event)
  {
   // The target_ variable contains the MainWindow object
   if ((object == target_)  (event-type() == QEvent::Move))
   {
   qWarning(=== filtering object %p / target %p, object,
 target_);
   followActivated(NULL);
   }
   return true;
  }
  =
 
  There's always a delay in moving the MainWindow and the follower moving
  to its right position.
 
  I'm puzzled. How did you succeed in having these two dialogs move
  simultaneously? Can you post an excerpt?
 
  Thanks  Cheers!

 Hi Sensei,

 My code is just:

 bool Slave::eventFilter(QObject *obj, QEvent *ev)
 {
   if (obj == Master)
  move( Master-frameGeometry().left() +
 Master-frameGeometry().width(),
 Master-frameGeometry().top() );

   return Ancestor::eventFilter(obj, ev);
 }

 Note that I do not return true - since I want the move to be handled by the
 Master as normal.

 The Master is the parent of the Slave, and the Slave is created with window
 flag Qt::Tool.

 Hope that helps,

 Tony.


 ___
 Interest mailing list
 Interest@qt-project.org javascript:;
 http://lists.qt-project.org/mailman/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Glueing widgets together

2013-06-29 Thread Sensei
Yes John, I'm on a Mac.

I think you're right. After dumping the whole event chain, I clearly see
that events are clustered: if there isn't a delay between them (I am fast
and constant dragging the window around), I get only one event when my
speed slows down.

So there's nothing I can do, right?

On Friday, June 28, 2013, John Weeks wrote:

 It sounds like you're trying to make two windows stay glued together. We
 have a similar problem. I have a similar solution, too. It works great on
 Windows, but on Macintosh the follower window waits until the mouse stops
 moving and then catches up.

 Is your problem on Macintosh?

 That behavior is unavoidable because Cocoa simply doesn't deliver the
 necessary events to Qt in a timely fashion. I know this because I found
 complaints about it on the Cocoa developer list. I've also seen no
 indication that Apple thinks its a problem.



 Dear all,

 I've posted some time ago a question about moving widgets simultaneously.
 However, the proposed solutions were unsatisfactory.

 That is probably because I've expressed my needs in a non useful way. So
 here it goes.

 I need to glue together two widgets, so that when one moves, the other
 *simultaneously* moves.

 They should appear glued even when dragging around, fast and slow. Like if
 the follower is simply painted over the moving widget.

 The proposed solutions involve getting the mouse move events dealt with.
 This resulted in a visible delay, and that isn't what I want: I don't want
 to see the window moving with the follower staying still, and after few
 instants, the follower (disappearing from where it was) painted in the
 right position.

 Is there any way I can achieve this visual effect?

 Thanks  Cheers!
 ___
 Interest mailing list
 Interest@qt-project.org javascript:_e({}, 'cvml',
 'Interest@qt-project.org');
 http://lists.qt-project.org/mailman/listinfo/interest


 -John Weeks


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] Glueing widgets together

2013-06-28 Thread Sensei
Dear all,

I've posted some time ago a question about moving widgets simultaneously.
However, the proposed solutions were unsatisfactory.

That is probably because I've expressed my needs in a non useful way. So
here it goes.

I need to glue together two widgets, so that when one moves, the other
*simultaneously* moves.

They should appear glued even when dragging around, fast and slow. Like if
the follower is simply painted over the moving widget.

The proposed solutions involve getting the mouse move events dealt with.
This resulted in a visible delay, and that isn't what I want: I don't want
to see the window moving with the follower staying still, and after few
instants, the follower (disappearing from where it was) painted in the
right position.

Is there any way I can achieve this visual effect?

Thanks  Cheers!
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] Glueing widgets together

2013-06-28 Thread Tony Rietwyk
Hi Sensei, 

 

I have a master dialog with a slave dialog attached to one border.  This was
done using eventFilter in the slave to listen to the master Move and Resize
events - not MouseMove.  It's only 10 lines of code, works well and there is
no jerkiness.  It put the code in the slave, since it can be attached to
many different dialogs in my app.  

 

The same code should work for peer dialogs - but you must be careful to
prevent recursion by settings flags in the other dialog before moving it so
it doesn't try to move the first one.  The recursion could cause the delays
and high CPU usage.  

 

Can you show the code that isn't working?  

 

Tony.

 

 

From: interest-bounces+tony=rightsoft.com...@qt-project.org
[mailto:interest-bounces+tony=rightsoft.com...@qt-project.org] On Behalf Of
Sensei
Sent: Friday, 28 June 2013 5:18 PM
To: interest@qt-project.org
Subject: [Interest] Glueing widgets together

 

Dear all,

 

I've posted some time ago a question about moving widgets simultaneously.
However, the proposed solutions were unsatisfactory. 

 

That is probably because I've expressed my needs in a non useful way. So
here it goes. 

 

I need to glue together two widgets, so that when one moves, the other
*simultaneously* moves. 

 

They should appear glued even when dragging around, fast and slow. Like if
the follower is simply painted over the moving widget. 

 

The proposed solutions involve getting the mouse move events dealt with.
This resulted in a visible delay, and that isn't what I want: I don't want
to see the window moving with the follower staying still, and after few
instants, the follower (disappearing from where it was) painted in the right
position. 

 

Is there any way I can achieve this visual effect?

 

Thanks  Cheers!

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest