70 QScreen *screen = widget->screen();
71 const QRect drect = screen->availableGeometry();
73 const int width = size.width(), height = size.height();
74 const QPoint gpos = widget->mapToGlobal(
pos);
75 const QRect irect(widget->mapToGlobal(option.rect.topLeft()), option.rect.size());
77 int y = gpos.y() + 20;
78 if (y + height > drect.bottom())
79 y = qMax(drect.top(), irect.top() - height);
82 if (gpos.x() + width < drect.right())
85 x = qMax(drect.left(), gpos.x() - width);