diff --git a/examples/widgets/mainwindows/mdi/main.cpp b/examples/widgets/mainwindows/mdi/main.cpp
index ab5f9b1..57c34ea 100644
--- a/examples/widgets/mainwindows/mdi/main.cpp
+++ b/examples/widgets/mainwindows/mdi/main.cpp
@@ -39,15 +39,166 @@
 ****************************************************************************/
 
 #include <QApplication>
+#include <QProxyStyle>
+#include <QFontMetrics>
+#include <QMetaObject>
+#include <QMenuBar>
+#include <QMetaEnum>
+#include <QVariant>
+#include <QPixmap>
+#include <QStyleOption>
+#include <QStyle>
+#include <QMainWindow>
+#include <QIcon>
+#include <QDebug>
+
+#define ENUM_DEBUG_OPERATOR(className, enumName) \
+QDebug operator<<(QDebug d, className::enumName v) \
+{ \
+    static const int ei = className::staticMetaObject.indexOfEnumerator(#enumName); \
+    QDebugStateSaver s(d); \
+    d.nospace(); \
+    d << className::staticMetaObject.enumerator(ei).key(v) << '[' << int(v) << ']'; \
+    return d; \
+}
+
+ENUM_DEBUG_OPERATOR(QStyle, StateFlag)
+ENUM_DEBUG_OPERATOR(QStyle, PrimitiveElement)
+ENUM_DEBUG_OPERATOR(QStyle, ControlElement)
+ENUM_DEBUG_OPERATOR(QStyle, SubElement)
+ENUM_DEBUG_OPERATOR(QStyle, ComplexControl)
+ENUM_DEBUG_OPERATOR(QStyle, SubControl)
+ENUM_DEBUG_OPERATOR(QStyle, PixelMetric)
+ENUM_DEBUG_OPERATOR(QStyle, ContentsType)
+ENUM_DEBUG_OPERATOR(QStyle, RequestSoftwareInputPanel)
+ENUM_DEBUG_OPERATOR(QStyle, StyleHint)
+ENUM_DEBUG_OPERATOR(QStyle, StandardPixmap)
+
+class DebugStyle : public QProxyStyle {
+    Q_OBJECT
+public:
+    static QString debugWidget(const QWidget *widget = 0)
+    {
+        if (!widget)
+            return QStringLiteral("widget=NULL");
+        const QString on = widget->objectName();
+        if (!on.isEmpty())
+            return on;
+        return widget->metaObject()->className();
+    }
+    static QString debugQStyleOption(const QStyleOption *option)
+    {
+        QString result;
+        if (option)
+            QDebug(&result) << "optRec=" << option->rect;
+        else
+            result = QStringLiteral("option=NULL");
+        return result;
+    }
+
+    DebugStyle(QStyle *style) : QProxyStyle(style)
+    {
+          qDebug() << __FUNCTION__ << style->objectName() << "devicePixelRatio=" << qApp->devicePixelRatio();
+    }
+
+    void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
+    {
+        qDebug() << __FUNCTION__ << "element="<< element
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget);
+        QProxyStyle::drawPrimitive( element, option, painter, widget);
+    }
+
+    void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const
+    {
+        qDebug() << __FUNCTION__ << "element="<< element
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget);
+        QProxyStyle::drawControl(element, option, painter, widget);
+    }
+    void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const
+    {
+        qDebug() << __FUNCTION__ << "control="<< control
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget);
+        QProxyStyle::drawComplexControl(control, option, painter, widget);
+    }
+    void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
+    {
+        qDebug() << __FUNCTION__ << rect << "alignment=" << alignment << pixmap;
+        QProxyStyle::drawItemPixmap(painter, rect, alignment, pixmap);
+    }
+
+    QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
+    {
+        QSize r= QProxyStyle::sizeFromContents(type, option, size, widget);
+        qDebug() << __FUNCTION__ << size << "type=" << type
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget) << "returns" << r;
+        return r;
+    }
+
+    QRect subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
+    {
+        QRect r = QProxyStyle::subElementRect(element, option, widget);
+        qDebug() << __FUNCTION__ << "element=" << element
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget) << "returns" << r;
+        return r;
+
+    }
+    QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *widget) const
+    {
+        QRect r = QProxyStyle::subControlRect(cc, opt, sc, widget);
+        qDebug() << __FUNCTION__ << "cc=" << cc << "sc=" << sc
+                 <<  DebugStyle::debugQStyleOption(opt) << DebugStyle::debugWidget(widget) << "returns" << r;
+        return r;
+    }
+    QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
+    {
+        QRect re = QProxyStyle::itemTextRect(fm, r, flags, enabled, text);
+        qDebug() << __FUNCTION__ <<  r << "flags=" << flags  << "enabled=" << enabled << text << "returns " << re;
+        return re;
+    }
+
+    QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
+    {
+        QRect re = QProxyStyle::itemPixmapRect(r, flags, pixmap);
+        qDebug() << __FUNCTION__ << r << "flags=" << flags  << pixmap << "returns " << re;
+        return re;
+    }
+
+    int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const
+    {
+        int r = QProxyStyle::pixelMetric(metric, option, widget);
+        qDebug() << __FUNCTION__ << "metric="<< metric
+                 << DebugStyle::debugQStyleOption(option) << DebugStyle::debugWidget(widget) << "returns" << r;
+        return r;
+    }
+
+    QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const
+    {
+        QPixmap r = QProxyStyle::standardPixmap(standardPixmap, opt, widget);
+        qDebug() << __FUNCTION__ << "standardPixmap=" << standardPixmap << "returns " << r;
+        return r;
+    }
+
+    QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
+    {
+        QPixmap r = QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt);
+        qDebug() << __FUNCTION__ << "iconMode=" << iconMode << pixmap << "returns " << r;
+        return r;
+    }
+}; // DebugStyle
 
 #include "mainwindow.h"
 
 int main(int argc, char *argv[])
 {
     Q_INIT_RESOURCE(mdi);
-
+    qDebug() << QT_VERSION_STR;
     QApplication app(argc, argv);
+    if (!QApplication::arguments().contains("-n"))
+        app.setStyle(new DebugStyle(QApplication::style()));
+
     MainWindow mainWin;
     mainWin.show();
     return app.exec();
 }
+
+#include "main.moc"
diff --git a/examples/widgets/mainwindows/mdi/mdi.pro b/examples/widgets/mainwindows/mdi/mdi.pro
index 2e3c232..839fc80 100644
--- a/examples/widgets/mainwindows/mdi/mdi.pro
+++ b/examples/widgets/mainwindows/mdi/mdi.pro
@@ -1,5 +1,5 @@
 QT += widgets
-
+CONFIG+=console
 HEADERS       = mainwindow.h \
                 mdichild.h
 SOURCES       = main.cpp \
diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index f523ac2..24f927b 100644
--- a/src/widgets/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
@@ -423,6 +423,7 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
                 icone = style->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
     for(int i = 0; i < actions.count(); i++) {
         QAction *action = actions.at(i);
+        qDebug() << __FUNCTION__ << action << q->font();
         if(!action->isVisible())
             continue;
 
@@ -437,16 +438,20 @@ void QMenuBarPrivate::calcActionRects(int max_width, int start) const
             const QString s = action->text();
             QIcon is = action->icon();
             // If an icon is set, only the icon is visible
-            if (!is.isNull())
+            if (!is.isNull()) {
                 sz = sz.expandedTo(QSize(icone, icone));
-            else if (!s.isEmpty())
+            } else if (!s.isEmpty()) {
+                qDebug() << __FUNCTION__ << "text" << s << fm.size(Qt::TextShowMnemonic, s);
                 sz = fm.size(Qt::TextShowMnemonic, s);
+            }
+            qDebug() << __FUNCTION__ << sz << "icone=" << icone;
         }
 
         //let the style modify the above size..
         QStyleOptionMenuItem opt;
         q->initStyleOption(&opt, action);
         sz = q->style()->sizeFromContents(QStyle::CT_MenuBarItem, &opt, sz, q);
+        qDebug() << __FUNCTION__ << "sizeFromContents" << sz;
 
         if(!sz.isEmpty()) {
             { //update the separator state
@@ -969,8 +974,9 @@ void QMenuBar::paintEvent(QPaintEvent *e)
 
     //draw the items
     for (int i = 0; i < d->actions.count(); ++i) {
-        QAction *action = d->actions.at(i);
+        QAction *action = d->actions.at(i);        
         QRect adjustedActionRect = d->actionRect(action);
+        qDebug() << __FUNCTION__ << i << adjustedActionRect;
         if (adjustedActionRect.isEmpty() || !d->isVisible(action))
             continue;
         if(!e->rect().intersects(adjustedActionRect))
