Warum?Qt setGeometry: Geometrie kann nicht eingestellt werden
setGeometry: Unable to set geometry 22x22+320+145 on QWidgetWindow/'WidgetClassWindow'. Resulting geometry: 116x22+320+145 (frame: 8, 30, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 22x22, maximum size: 16777215x16777215).
Das Projekt ist:
project.pro
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled5
TEMPLATE = app
SOURCES += main.cpp\
widget.cpp
HEADERS += widget.h
widget.h
#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
private:
};
#endif // WIDGET_H
widget.cpp
#include "widget.h"
#include <QVBoxLayout>
Widget::Widget(QWidget *parent) :
QWidget(parent)
{
QVBoxLayout *vLayout = new QVBoxLayout(this);
}
Widget::~Widget()
{
}
main.cpp
#include "widget.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();
return a.exec();
}
Hinzufügen setGeometry (0, 0, 400, 300); im Widget-Konstruktor entfernt das Problem. Aber das Fenster wird nicht schön in der Mitte des Bildschirms positioniert.
möchten Sie Ihr Anwendungsfenster in der Mitte des Bildschirms? –