Restrict QFontComboBox's popup width to screen width

Change-Id: I5a92308beb2f245d9f031918bb8154757316ef56
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
This commit is contained in:
Fabian Bumberger 2014-04-10 15:09:42 +02:00 committed by The Qt Project
parent ff34070709
commit bfb25c0352

View File

@ -50,6 +50,7 @@
#include <qevent.h>
#include <qapplication.h>
#include <private/qcombobox_p.h>
#include <QDesktopWidget>
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@ -546,8 +547,10 @@ bool QFontComboBox::event(QEvent *e)
{
if (e->type() == QEvent::Resize) {
QListView *lview = qobject_cast<QListView*>(view());
if (lview)
lview->window()->setFixedWidth(width() * 5 / 3);
if (lview) {
setFixedWidth(qMin(width() * 5 / 3,
QApplication::desktop()->availableGeometry(lview).width()));
}
}
return QComboBox::event(e);
}