Reputation: 5246
I have a QtQuick2.0/QtQuick2.1 application with following default codes on main.cpp
:
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
viewer.setMainQmlFile(QStringLiteral("qml/WikiTransferor2/mainMode3.qml"));
viewer.showExpanded();
return app.exec();
}
How can i make this window not resizable?
Upvotes: 6
Views: 14918
Reputation: 5300
On (at least) KDE the other answers don't work. The following QtQuick solution worked for me:
ApplicationWindow{
width: ...
height: ...
maximumHeight: height
maximumWidth: width
minimumHeight: height
minimumWidth: width
}
Upvotes: 23
Reputation: 3153
For those coming here from google like me, searching for a QML/QtQuick solution, because they are using the ApplicationWindow
Item, I add this answer.
Simply set the maximum height/width to the minimum height/width:
ApplicationWindow {
visible: true
maximumHeight: minimumHeight
maximumWidth: minimumWidth
[...]
}
Please note that you should not deactivate the window resizing if there are other possibilities (like resizing the content). The users don't like unresizable windows. For instance, in my case, I only locked the height - because I had the possibility to resize some elements in their width: My QML Slider uses as much space as there is available thanks to QtQuick Layouts. However, resizing a few Buttons and a slider in their height would not make sense. TableViews, TextFields etc., however, are predestinated for being resized.
Upvotes: 5
Reputation: 1147
Like all QWindow : using flags or with setting min and max size with same value
Upvotes: 3