Fix warnings about not being able to set Window geometry on Windows.

Fully decorated windows cannot be smaller than 160x30 (Large fonts).
Enlarge Windows or remove Window frame  to get rid of decorations.

Task-number: QTBUG-28611
Change-Id: Idb6ee94fb8d0760d5f97042b3084557f11e9fdf9
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
This commit is contained in:
Friedemann Kleint 2012-12-28 17:35:54 +01:00 committed by The Qt Project
parent 41acb58f23
commit 54fd35b134
17 changed files with 171 additions and 5 deletions

View File

@ -172,10 +172,10 @@ void tst_QDialog::showExtension_data()
QTest::addColumn<QSize>("result");
//next we fill it with data
QTest::newRow( "data0" ) << QSize(100,100) << QSize(50,50) << false << QSize(100,150);
QTest::newRow( "data1" ) << QSize(100,100) << QSize(120,50) << false << QSize(120,150);
QTest::newRow( "data2" ) << QSize(100,100) << QSize(50,50) << true << QSize(150,100);
QTest::newRow( "data3" ) << QSize(100,100) << QSize(50,120) << true << QSize(150,120);
QTest::newRow( "data0" ) << QSize(200,100) << QSize(50,50) << false << QSize(200,150);
QTest::newRow( "data1" ) << QSize(200,100) << QSize(220,50) << false << QSize(220,150);
QTest::newRow( "data2" ) << QSize(200,100) << QSize(50,50) << true << QSize(250,100);
QTest::newRow( "data3" ) << QSize(200,100) << QSize(50,120) << true << QSize(250,120);
}
void tst_QDialog::showExtension()

View File

@ -7889,6 +7889,7 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption()
scene.addItem(rect);
rect->setPos(200, 200);
QWidget topLevel;
topLevel.resize(200, 200);
QGraphicsView view(&scene, &topLevel);
topLevel.setWindowFlags(Qt::X11BypassWindowManagerHint);
rect->startTrack = false;

View File

@ -133,6 +133,14 @@ class FriendlyGraphicsScene : public QGraphicsScene
};
#endif
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QGraphicsView : public QObject
{
Q_OBJECT
@ -366,6 +374,7 @@ void tst_QGraphicsView::alignment()
scene.addRect(QRectF(-10, -10, 20, 20));
QGraphicsView view(&scene);
setFrameless(&view);
view.show();
QVERIFY(QTest::qWaitForWindowExposed(&view));
@ -649,6 +658,7 @@ void tst_QGraphicsView::dragMode_scrollHand()
{
for (int j = 0; j < 2; ++j) {
QGraphicsView view;
setFrameless(&view);
QCOMPARE(view.dragMode(), QGraphicsView::NoDrag);
view.setSceneRect(-1000, -1000, 2000, 2000);
@ -875,6 +885,7 @@ void tst_QGraphicsView::dragMode_rubberBand()
void tst_QGraphicsView::rubberBandSelectionMode()
{
QWidget toplevel;
setFrameless(&toplevel);
QGraphicsScene scene;
QGraphicsRectItem *rect = scene.addRect(QRectF(10, 10, 80, 80));
@ -1094,6 +1105,7 @@ void tst_QGraphicsView::matrix_combine()
void tst_QGraphicsView::centerOnPoint()
{
QWidget toplevel;
setFrameless(&toplevel);
QGraphicsScene scene;
scene.addEllipse(QRectF(-100, -100, 50, 50));
@ -1757,6 +1769,7 @@ void tst_QGraphicsView::mapToScenePoint()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
setFrameless(&view);
view.rotate(90);
view.setFixedSize(117, 117);
view.show();
@ -1816,6 +1829,7 @@ void tst_QGraphicsView::mapToScenePoly()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
setFrameless(&view);
view.translate(100, 100);
view.setFixedSize(117, 117);
view.show();
@ -2197,6 +2211,7 @@ void tst_QGraphicsView::transformationAnchor()
scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue));
QGraphicsView view(&scene);
setFrameless(&view);
for (int i = 0; i < 2; ++i) {
view.resize(100, 100);
@ -2235,6 +2250,7 @@ void tst_QGraphicsView::resizeAnchor()
scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue));
QGraphicsView view(&scene);
setFrameless(&view);
for (int i = 0; i < 2; ++i) {
view.resize(100, 100);
@ -3175,6 +3191,7 @@ void tst_QGraphicsView::task239047_fitInViewSmallViewport()
// Ensure that with a small viewport, fitInView doesn't mirror the
// scene.
QWidget widget;
setFrameless(&widget);
QGraphicsScene scene;
QGraphicsView *view = new QGraphicsView(&scene, &widget);
view->resize(3, 3);
@ -4434,6 +4451,7 @@ void tst_QGraphicsView::QTBUG_4151_clipAndIgnore()
scene.addItem(ignore);
QGraphicsView view(&scene);
setFrameless(&view);
view.setFrameStyle(0);
view.resize(75, 75);
view.show();
@ -4592,6 +4610,7 @@ void tst_QGraphicsView::QTBUG_16063_microFocusRect()
scene.addItem(item);
QGraphicsView view(&scene);
setFrameless(&view);
view.setFixedSize(40, 40);
view.show();

View File

@ -70,6 +70,14 @@
QCOMPARE(expr, expected); \
} while(0)
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class TestView : public QAbstractItemView
{
Q_OBJECT
@ -621,6 +629,7 @@ void tst_QAbstractItemView::noModel()
QStandardItemModel model(20,20);
QTreeView view;
setFrameless(&view);
view.setModel(&model);
// Make the viewport smaller than the contents, so that we can scroll

View File

@ -70,6 +70,16 @@ static inline HWND getHWNDForWidget(const QWidget *widget)
}
#endif // Q_OS_WIN
// Make a widget frameless to prevent size constraints of title bars
// from interfering (Windows).
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QListView : public QObject
{
Q_OBJECT
@ -1178,6 +1188,7 @@ void tst_QListView::selection()
void tst_QListView::scrollTo()
{
QWidget topLevel;
setFrameless(&topLevel);
QListView lv(&topLevel);
QStringListModel model(&lv);
QStringList list;
@ -1842,6 +1853,7 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenItems()
const int rowCount = 200;
QWidget topLevel;
setFrameless(&topLevel);
QListView view(&topLevel);
QStringListModel model(&view);
QStringList list;
@ -1993,6 +2005,7 @@ void tst_QListView::taskQTBUG_9455_wrongScrollbarRanges()
QStringListModel model(list);
ListView_9455 w;
setFrameless(&w);
w.setModel(&model);
w.setViewMode(QListView::IconMode);
w.resize(116, 132);

View File

@ -57,6 +57,16 @@ typedef QList<int> IntList;
typedef QList<bool> BoolList;
// Make a widget frameless to prevent size constraints of title bars
// from interfering (Windows).
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QTableView : public QObject
{
Q_OBJECT
@ -2147,6 +2157,7 @@ void tst_QTableView::rowViewportPosition()
QtTestTableModel model(rowCount, 1);
QtTestTableView view;
setFrameless(&view);
view.resize(100, 2 * rowHeight);
view.show();
@ -2309,6 +2320,7 @@ void tst_QTableView::columnViewportPosition()
QtTestTableModel model(1, columnCount);
QtTestTableView view;
setFrameless(&view);
view.resize(2 * columnWidth, 100);
view.show();
@ -2586,6 +2598,7 @@ void tst_QTableView::scrollTo()
QtTestTableModel model(rowCount, columnCount);
QWidget toplevel;
setFrameless(&toplevel);
QtTestTableView view(&toplevel);
toplevel.show();
@ -3343,6 +3356,7 @@ void tst_QTableView::tabFocus()
// to change focus on an empty table view, or on a table view that doesn't
// have this property set.
QWidget window;
window.resize(200, 200);
QTableView *view = new QTableView(&window);
QLineEdit *edit = new QLineEdit(&window);

View File

@ -111,6 +111,16 @@ struct PublicView : public QTreeView
QAbstractItemViewPrivate* aiv_priv() { return static_cast<QAbstractItemViewPrivate*>(d_ptr.data()); }
};
// Make a widget frameless to prevent size constraints of title bars
// from interfering (Windows).
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QTreeView : public QObject
{
Q_OBJECT
@ -877,6 +887,7 @@ void tst_QTreeView::horizontalScrollMode()
}
QTreeView view;
setFrameless(&view);
view.setModel(&model);
view.setFixedSize(100, 100);
view.header()->resizeSection(0, 200);
@ -3417,6 +3428,7 @@ void tst_QTreeView::task224091_appendColumns()
{
QStandardItemModel *model = new QStandardItemModel();
QWidget* topLevel= new QWidget;
setFrameless(topLevel);
QTreeView *treeView = new QTreeView(topLevel);
treeView->setModel(model);
topLevel->show();

View File

@ -1945,6 +1945,7 @@ void tst_QApplication::touchEventPropagation()
{
// touch event behavior on a window
TouchEventPropagationTestWidget window;
window.resize(200, 200);
window.setObjectName("1. window");
window.show(); // Must have an explicitly specified QWindow for handleTouchEvent,
// passing 0 would result in using topLevelAt() which is not ok in this case
@ -1999,6 +2000,7 @@ void tst_QApplication::touchEventPropagation()
{
// touch event behavior on a window with a child widget
TouchEventPropagationTestWidget window;
window.resize(200, 200);
window.setObjectName("2. window");
TouchEventPropagationTestWidget widget(&window);
widget.setObjectName("2. widget");

View File

@ -44,6 +44,14 @@
#include <QtGui>
#include <QtWidgets>
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QBoxLayout : public QObject
{
Q_OBJECT
@ -198,6 +206,7 @@ void tst_QBoxLayout::sizeConstraints()
void tst_QBoxLayout::setGeometry()
{
QWidget toplevel;
setFrameless(&toplevel);
QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout;
lay->setMargin(0);

View File

@ -55,6 +55,14 @@
#include <qformlayout.h>
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QFormLayout : public QObject
{
Q_OBJECT
@ -345,6 +353,7 @@ void tst_QFormLayout::spacing()
void tst_QFormLayout::contentsRect()
{
QWidget w;
setFrameless(&w);
QFormLayout form;
w.setLayout(&form);
form.addRow("Label", new QPushButton(&w));

View File

@ -57,6 +57,14 @@
#include <QRadioButton>
#include <private/qlayoutengine_p.h>
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QLayout : public QObject
{
Q_OBJECT
@ -126,6 +134,7 @@ void tst_QLayout::geometry()
// should be the same.
QApplication::setStyle(QStyleFactory::create(QLatin1String("Windows")));
QWidget topLevel;
setFrameless(&topLevel);
QWidget w(&topLevel);
QVBoxLayout layout(&w);
SizeHinterFrame widget(QSize(100,100));

View File

@ -213,7 +213,7 @@ void tst_QShortcut::initTestCase()
mainW = new QMainWindow(0);
mainW->setWindowFlags(Qt::X11BypassWindowManagerHint);
edit = new TestEdit(mainW, "test_edit");
mainW->setFixedSize( 100, 100 );
mainW->setFixedSize( 200, 200 );
mainW->setCentralWidget( edit );
mainW->show();
mainW->activateWindow();

View File

@ -154,6 +154,16 @@ bool macHasAccessToWindowsServer()
}
#endif
// Make a widget frameless to prevent size constraints of title bars
// from interfering (Windows).
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QWidget : public QObject
{
Q_OBJECT
@ -1969,6 +1979,7 @@ void tst_QWidget::showMaximized()
{
QWidget widget;
setFrameless(&widget);
widget.setGeometry(0, 0, 10, 10);
widget.showMaximized();
QTRY_VERIFY(widget.size().width() > 20 && widget.size().height() > 20);
@ -2080,6 +2091,7 @@ void tst_QWidget::resizeEvent()
{
{
QWidget wParent;
wParent.resize(200, 200);
ResizeWidget wChild(&wParent);
wParent.show();
QCOMPARE (wChild.m_resizeEventCount, 1); // initial resize event before paint
@ -2095,6 +2107,7 @@ void tst_QWidget::resizeEvent()
{
ResizeWidget wTopLevel;
wTopLevel.resize(200, 200);
wTopLevel.show();
QCOMPARE (wTopLevel.m_resizeEventCount, 1); // initial resize event before paint for toplevels
wTopLevel.hide();
@ -2182,6 +2195,7 @@ void tst_QWidget::showMinimizedKeepsFocus()
//testing deletion of the focusWidget
{
QWidget window;
window.resize(200, 200);
QWidget *child = new QWidget(&window);
child->setFocusPolicy(Qt::StrongFocus);
window.show();
@ -2199,6 +2213,7 @@ void tst_QWidget::showMinimizedKeepsFocus()
//testing reparenting the focus widget
{
QWidget window;
window.resize(200, 200);
QWidget *child = new QWidget(&window);
child->setFocusPolicy(Qt::StrongFocus);
window.show();
@ -2216,6 +2231,7 @@ void tst_QWidget::showMinimizedKeepsFocus()
//testing setEnabled(false)
{
QWidget window;
window.resize(200, 200);
QWidget *child = new QWidget(&window);
child->setFocusPolicy(Qt::StrongFocus);
window.show();
@ -2233,6 +2249,7 @@ void tst_QWidget::showMinimizedKeepsFocus()
//testing clearFocus
{
QWidget window;
window.resize(200, 200);
QWidget *firstchild = new QWidget(&window);
firstchild->setFocusPolicy(Qt::StrongFocus);
QWidget *child = new QWidget(&window);
@ -4501,6 +4518,7 @@ void tst_QWidget::setWindowGeometry()
void tst_QWidget::setGeometry_win()
{
QWidget widget;
setFrameless(&widget);
widget.setGeometry(0, 600, 100,100);
widget.show();
widget.setWindowState(widget.windowState() | Qt::WindowMaximized);
@ -5727,6 +5745,7 @@ void tst_QWidget::childEvents()
{
// no children created, not shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -5746,6 +5765,7 @@ void tst_QWidget::childEvents()
{
// no children, shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -5786,6 +5806,7 @@ void tst_QWidget::childEvents()
{
// 2 children, not shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -5821,6 +5842,7 @@ void tst_QWidget::childEvents()
{
// 2 children, widget shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -5877,6 +5899,7 @@ void tst_QWidget::childEvents()
{
// 2 children, but one is reparented away, not shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -5913,6 +5936,7 @@ void tst_QWidget::childEvents()
{
// 2 children, but one is reparented away, then widget is shown
QWidget widget;
widget.resize(200, 200);
EventRecorder spy;
widget.installEventFilter(&spy);
@ -7328,6 +7352,7 @@ void tst_QWidget::alienWidgets()
QWidget *toolBar = new QWidget(&mainWindow);
QWidget *dockWidget = new QWidget(&mainWindow);
QWidget *centralWidget = new QWidget(&mainWindow);
centralWidget->setMinimumSize(QSize(200, 200));
QWidget *button = new QWidget(centralWidget);
QWidget *mdiArea = new QWidget(centralWidget);
@ -7844,6 +7869,7 @@ void tst_QWidget::immediateRepaintAfterInvalidateBuffer()
void tst_QWidget::effectiveWinId()
{
QWidget parent;
parent.resize(200, 200);
QWidget child(&parent);
// Shouldn't crash.

View File

@ -53,6 +53,13 @@
#include <qpushbutton.h>
#include <qboxlayout.h>
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QWidget_window : public QWidget
{
@ -116,6 +123,7 @@ void tst_QWidget_window::tst_min_max_size()
const QSize minSize(300, 400);
const QSize maxSize(1000, 500);
QWidget w1;
setFrameless(&w1);
(new QVBoxLayout(&w1))->addWidget(new QPushButton("Test"));
if (setMinMaxSizeBeforeShow) {
w1.setMinimumSize(minSize);

View File

@ -51,6 +51,14 @@
#include <qmainwindow.h>
#include <qmenubar.h>
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class tst_QWidgetAction : public QObject
{
Q_OBJECT
@ -98,6 +106,7 @@ void tst_QWidgetAction::defaultWidget()
}
{
QPointer<QComboBox> combo = new QComboBox(0);
setFrameless(combo.data());
combo->show();
QWidgetAction *action = new QWidgetAction(0);
@ -110,8 +119,10 @@ void tst_QWidgetAction::defaultWidget()
}
{
QToolBar tb1;
setFrameless(&tb1);
tb1.show();
QToolBar tb2;
setFrameless(&tb2);
tb2.show();
QPointer<QComboBox> combo = new QComboBox(0);
@ -175,6 +186,7 @@ void tst_QWidgetAction::visibilityUpdate()
// actually keeping the widget's state in sync with the
// action in terms of visibility is QToolBar's responsibility.
QToolBar tb;
setFrameless(&tb);
tb.show();
QComboBox *combo = new QComboBox(0);
@ -213,8 +225,10 @@ QWidget *ComboAction::createWidget(QWidget *parent)
void tst_QWidgetAction::customWidget()
{
QToolBar tb1;
setFrameless(&tb1);
tb1.show();
QToolBar tb2;
setFrameless(&tb2);
tb2.show();
ComboAction *action = new ComboAction(0);
@ -273,6 +287,7 @@ void tst_QWidgetAction::visibility()
a->setDefaultWidget(combo);
QToolBar *tb = new QToolBar;
setFrameless(tb);
tb->addAction(a);
QVERIFY(!combo->isVisible());
tb->show();
@ -292,6 +307,7 @@ void tst_QWidgetAction::visibility()
QVERIFY(!combo->isVisible());
QToolBar *tb2 = new QToolBar;
setFrameless(tb2);
tb->removeAction(a);
tb2->addAction(a);
QVERIFY(!combo->isVisible());
@ -308,6 +324,7 @@ void tst_QWidgetAction::visibility()
void tst_QWidgetAction::setEnabled()
{
QToolBar toolbar;
setFrameless(&toolbar);
QComboBox *combobox = new QComboBox;
QAction *action = toolbar.addWidget(combobox);
toolbar.show();

View File

@ -49,6 +49,14 @@
#include "../../../../shared/filesystem.h"
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class CsvCompleter : public QCompleter
{
Q_OBJECT
@ -1282,6 +1290,7 @@ private slots:
void tst_QCompleter::task246056_setCompletionPrefix()
{
task246056_ComboBox *comboBox = new task246056_ComboBox;
setFrameless(comboBox);
QVERIFY(comboBox->completer());
comboBox->addItem("");
comboBox->addItem("a1");

View File

@ -52,6 +52,14 @@
// defined to be 120 by the wheel mouse vendors according to the docs
#define WHEEL_DELTA 120
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
flags |= Qt::FramelessWindowHint;
flags &= ~(Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint);
w->setWindowFlags(flags);
}
class Slider : public QAbstractSlider
{
public:
@ -937,6 +945,7 @@ void tst_QAbstractSlider::sliderPressedReleased()
QFETCH(int, expectedCount);
QWidget topLevel;
setFrameless(&topLevel);
QAbstractSlider *slider;
switch (control) {
default: