PDA

View Full Version : Changing window states breaks window manager



sebastian.f
29th June 2009, 14:15
Hello,

I am trying to build a simple application for Windows CE. At the moment I have a menu and a button.
The menu is accessible by right clicking the main window (QDialog); I use the 'popup' method called from the mousePress event handler rather than the menu-request signal.

The button simply exists at the moment.

The program works fine until I use my menu to change the state of the screen (Maximized, Free or Full Screen) as soon as the state changes it all falls apart:

On each right click the menu instance remains visible.
The contents of the window are not repainted when it is moved.
The child objects including the button are no longer drawn.

If I remove the button everything works fine.
If I add text to the button it becomes worse and I get stack overflow errors stemming from the itemizer function called as part of the process of drawing the text when the button recieves a paint event.


I am quite stuck! Does anyone know what may be causing this?

nish
29th June 2009, 14:39
try to create a very minimal compilable program reproducing the problem. post the code here.

sebastian.f
29th June 2009, 15:32
Hello MrDeath,

The code below causes the problem:

main.cpp:

#include <QApplication>
#include "user_interface.h"

int _tmain(int argc, char* argv[])
{
QApplication a(argc, argv);

UserInterface* gui = new UserInterface();
gui->show();

return a.exec();
}

user_interface.h:

#include <QDialog>
#include <QMenu>
#include <QMouseEvent>
#include <QPushButton>

class UserInterface : public QDialog
{
Q_OBJECT
public:
UserInterface(QWidget* parent = 0) : QDialog(parent)
{
resize(400, 300);
move(0, 0);
setWindowState(0);

context_menu = new QMenu(this);
context_menu->setContextMenuPolicy( Qt::NoContextMenu );

context_menu->addAction("Maximize",
this,
SLOT(menu_maximized()), 0 );
context_menu->addAction("Full screen",
this,
SLOT(menu_fullscreen()),0 );
context_menu->addAction("Free",
this,
SLOT(menu_free()), 0 );

finish_button = new QPushButton(this); //comment this out and everything works fine!


}

private:
QMenu* context_menu;
QPushButton* finish_button;

void mousePressEvent(QMouseEvent *e)
{
if( e->button() == Qt::RightButton )
{ context_menu->popup(e->globalPos());
}
}


private slots:
void menu_maximized()
{
setWindowState(Qt::WindowMaximized);
}
void menu_free()
{
setWindowState(Qt::WindowNoState);
}
void menu_fullscreen()
{
setWindowState(Qt::WindowFullScreen);
}


};

As you can see its very simple, I dont know what could be causing it.

It works fine until the window state changes (using the context menu) then the problems arise, until then I can bring up and close the menu and use the button OK.

I should mention i've built Qt specifically for my CE device, although the only difference between mine and the standard is that I built it with QT_FORCE_CREATE_GUID.

Edit: update - I've been working on the program as far as possible (without buttons) and I am also receiveing a stack overflow error when using the static method getText() of QInputDialog.

sebastian.f
30th June 2009, 14:40
Ok, Solved!

The stack overflow error wasn't caused by a bug, but simply that the default size on Windows CE is 64K whereas it is 1Mb on Windows desktops (dont know about mac or *nix).

Changing the size of the stack in the linker options to 1 megabyte (Binary not Decimal mega - that mistake cost me half a day! ;)) removes all the problems.

Would anyone be able to tell me for future reference what the stack size should be/what Qt has acctuall been designed for?

Thanks!