Results 1 to 4 of 4

Thread: Changing window states breaks window manager

  1. #1
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Changing window states breaks window manager

    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?

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing window states breaks window manager

    try to create a very minimal compilable program reproducing the problem. post the code here.

  3. #3
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing window states breaks window manager

    Hello MrDeath,

    The code below causes the problem:

    main.cpp:
    Qt Code:
    1. #include <QApplication>
    2. #include "user_interface.h"
    3.  
    4. int _tmain(int argc, char* argv[])
    5. {
    6. QApplication a(argc, argv);
    7.  
    8. UserInterface* gui = new UserInterface();
    9. gui->show();
    10.  
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    user_interface.h:
    Qt Code:
    1. #include <QDialog>
    2. #include <QMenu>
    3. #include <QMouseEvent>
    4. #include <QPushButton>
    5.  
    6. class UserInterface : public QDialog
    7. {
    8. Q_OBJECT
    9. public:
    10. UserInterface(QWidget* parent = 0) : QDialog(parent)
    11. {
    12. resize(400, 300);
    13. move(0, 0);
    14. setWindowState(0);
    15.  
    16. context_menu = new QMenu(this);
    17. context_menu->setContextMenuPolicy( Qt::NoContextMenu );
    18.  
    19. context_menu->addAction("Maximize",
    20. this,
    21. SLOT(menu_maximized()), 0 );
    22. context_menu->addAction("Full screen",
    23. this,
    24. SLOT(menu_fullscreen()),0 );
    25. context_menu->addAction("Free",
    26. this,
    27. SLOT(menu_free()), 0 );
    28.  
    29. finish_button = new QPushButton(this); //comment this out and everything works fine!
    30.  
    31.  
    32. }
    33.  
    34. private:
    35. QMenu* context_menu;
    36. QPushButton* finish_button;
    37.  
    38. void mousePressEvent(QMouseEvent *e)
    39. {
    40. if( e->button() == Qt::RightButton )
    41. { context_menu->popup(e->globalPos());
    42. }
    43. }
    44.  
    45.  
    46. private slots:
    47. void menu_maximized()
    48. {
    49. setWindowState(Qt::WindowMaximized);
    50. }
    51. void menu_free()
    52. {
    53. setWindowState(Qt::WindowNoState);
    54. }
    55. void menu_fullscreen()
    56. {
    57. setWindowState(Qt::WindowFullScreen);
    58. }
    59.  
    60.  
    61. };
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by sebastian.f; 29th June 2009 at 15:54.

  4. #4
    Join Date
    Apr 2009
    Posts
    19
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Changing window states breaks window manager

    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!
    Last edited by sebastian.f; 30th June 2009 at 14:48.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.