c++ - Qt setGeometry: Unable to set geometry -


why?

setgeometry: unable 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). 

the project is:

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(); } 

adding setgeometry(0, 0, 400, 300); in widget constructor removes issue. window not positioned beautifully @ center of screen.

this warning happens (at least me) when size of widget results small.

set minimum size widget (so automatically positioned), like:

 // widget constructor   qvboxlayout* vlayout = new qvboxlayout();  setlayout(vlayout);   setminimumsize(200,200); 

you should parent widget qmainwindow, still work.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -