jhowland
9th January 2011, 22:00
I am drawing a QGLWidget based map in a widget based main program (ie, no main window, just a widget).
When I draw my map and use a layout (call it H) to draw it into my widget, all is fine
If, however, I don't draw the map into H, but instead I make a widget that includes a QGroupBox, my map, and a couple of buttons, make a new layout (call it "V") , add the map and buttons into the layout, and then set QGroupBox layout to be "V", and then add the Groupbox to Layout H, everything compiles and runs without error--but my application shows up as a very small widget with no apparent content. When I enlarge it with the mouse, it is drawn just how I want it to be--all the buttons and map are drawn properly
my question is why isn't it drawn right the first time? I have tried explicitly setting sizes, etc, and it makes no difference. Is there something special about group boxes and layouts? Or something about a QGLWIdget?
here is the code that doesn't draw properly
NavMapWidget::NavMapWidget(IniFile *iniFile,QWidget *parent) :
QWidget(parent)
{
navMap = new NavMap(iniFile);
mapFrame = new QGroupBox;
zoomInButton = new QPushButton("Zoom in");
zoomOutButton = new QPushButton("Zoom out");
QGridLayout *widgetLayout = new QGridLayout;
widgetLayout->addWidget(navMap,0,0);
widgetLayout->addWidget(zoomInButton,1,0);
widgetLayout->addWidget(zoomOutButton,1,1);
mapFrame->setLayout(widgetLayout);
QVBoxLayout *mainMapLayout = new QVBoxLayout(this);
mainMapLayout->addWidget(mapFrame);
}
navMapWidget = new NavMapWidget(&iniFile,(QWidget *)this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(navMapWidget);
setLayout(mainLayout);
thanks in advance
Jonathan Howland
When I draw my map and use a layout (call it H) to draw it into my widget, all is fine
If, however, I don't draw the map into H, but instead I make a widget that includes a QGroupBox, my map, and a couple of buttons, make a new layout (call it "V") , add the map and buttons into the layout, and then set QGroupBox layout to be "V", and then add the Groupbox to Layout H, everything compiles and runs without error--but my application shows up as a very small widget with no apparent content. When I enlarge it with the mouse, it is drawn just how I want it to be--all the buttons and map are drawn properly
my question is why isn't it drawn right the first time? I have tried explicitly setting sizes, etc, and it makes no difference. Is there something special about group boxes and layouts? Or something about a QGLWIdget?
here is the code that doesn't draw properly
NavMapWidget::NavMapWidget(IniFile *iniFile,QWidget *parent) :
QWidget(parent)
{
navMap = new NavMap(iniFile);
mapFrame = new QGroupBox;
zoomInButton = new QPushButton("Zoom in");
zoomOutButton = new QPushButton("Zoom out");
QGridLayout *widgetLayout = new QGridLayout;
widgetLayout->addWidget(navMap,0,0);
widgetLayout->addWidget(zoomInButton,1,0);
widgetLayout->addWidget(zoomOutButton,1,1);
mapFrame->setLayout(widgetLayout);
QVBoxLayout *mainMapLayout = new QVBoxLayout(this);
mainMapLayout->addWidget(mapFrame);
}
navMapWidget = new NavMapWidget(&iniFile,(QWidget *)this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(navMapWidget);
setLayout(mainLayout);
thanks in advance
Jonathan Howland