Results 1 to 14 of 14

Thread: hide() quits?

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default hide() quits?

    I have a strange problem. I made a simple app with a button, and connected the buttons clicked() to hide() of the mainwindow. When clicking this button the app crashed in windows 2000. I'm using Qt 4.
    The program works fine in Linux. Strange. Is this a known bug or something else important that I have missed?

    This is main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "mainwindow.h"
    3. int main(int argc, char *argv[])
    4. { QApplication app(argc, argv);
    5. MainWindow *MainForm = new MainWindow;
    6. MainForm->show();
    7. return app.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 
    This is mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include "ui_mainwindow.h"
    6.  
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10. public:
    11. MainWindow(QWidget * parent = 0);
    12. private:
    13. Ui::MainWindow ui;
    14. };
    15.  
    16. #endif
    To copy to clipboard, switch view to plain text mode 

    this is mainwindow.cpp
    Qt Code:
    1. #include <QtGui>
    2. #include "mainwindow.h"
    3. MainWindow::MainWindow(QWidget *parent)
    4. : QMainWindow(parent, 0)
    5. { ui.setupUi(this);
    6. }
    To copy to clipboard, switch view to plain text mode 

    this is the ui file
    Qt Code:
    1. <ui version="4.0" >
    2. <author></author>
    3. <comment></comment>
    4. <exportmacro></exportmacro>
    5. <class>MainWindow</class>
    6. <widget class="QMainWindow" name="MainWindow" >
    7. <property name="geometry" >
    8. <rect>
    9. <x>0</x>
    10. <y>0</y>
    11. <width>425</width>
    12. <height>248</height>
    13. </rect>
    14. </property>
    15. <property name="windowTitle" >
    16. <string>Test QT DevCPP</string>
    17. </property>
    18. <widget class="QWidget" name="centralWidget" >
    19. <widget class="QPushButton" name="pushButton" >
    20. <property name="geometry" >
    21. <rect>
    22. <x>40</x>
    23. <y>80</y>
    24. <width>75</width>
    25. <height>24</height>
    26. </rect>
    27. </property>
    28. <property name="text" >
    29. <string>PushButton</string>
    30. </property>
    31. </widget>
    32. </widget>
    33. </widget>
    34. <pixmapfunction></pixmapfunction>
    35. <resources/>
    36. <connections>
    37. <connection>
    38. <sender>pushButton</sender>
    39. <signal>clicked()</signal>
    40. <receiver>MainWindow</receiver>
    41. <slot>hide()</slot>
    42. <hints>
    43. <hint type="sourcelabel" >
    44. <x>81</x>
    45. <y>114</y>
    46. </hint>
    47. <hint type="destinationlabel" >
    48. <x>216</x>
    49. <y>146</y>
    50. </hint>
    51. </hints>
    52. </connection>
    53. </connections>
    54. </ui>
    To copy to clipboard, switch view to plain text mode 

    I can't see anything strange with this, can you?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Which Qt version do you use on windows?

  3. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    4.1.0 (open source)
    It is compiled without debug.
    Mingw 3.4.2 is the compiler.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Then there should be no problems. How does it crash?

  5. #5
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    It just disapear. I run the task manager at the same time, it appears there, but when I click it, it disappear. Really strange.

    I updated this posting with the exe file (zipped) if some brave OR curios person want to try it out. There also seems to be some kind of a little delay, it doesn't quit/crash directly. But this is hard to tell if it really happens.
    Attached Files Attached Files
    • File Type: zip a.zip (14.5 KB, 1 views)
    Last edited by Morea; 23rd February 2006 at 19:09.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Quote Originally Posted by Morea
    It just disapear. I run the task manager at the same time, it appears there, but when I click it, it disappear.
    It doesn't crash, it just closes itself.

    From QApplication docs:
    quitOnLastWindowClosed : bool
    This property holds whether the application implicitly quits when the last window is closed.
    The default is true.
    If this property is true, the applications quits when the last visible primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose attribute set is closed. By default this attribute is set for all widgets except transient windows such as splash screens, tool windows, and popup menus.
    Access functions:
    bool quitOnLastWindowClosed ()
    void setQuitOnLastWindowClosed ( bool quit )
    See also quit() and QWidget::close().

  7. #7
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Oh! Thank you very much!
    I think it was showMinimized() I was looking for.
    Last edited by Morea; 23rd February 2006 at 19:38.

  8. #8
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: hide() quits?

    In my opinion it couldn't be better.
    How would you ever do something with your mainwindow if everything is hidden? For instance how would you make it visible again?

  9. #9
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    You are right. I thought it was possible to get it back again.
    Learning is fun!

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Quote Originally Posted by Morea
    I thought it was possible to get it back again.
    It will be possible, if you switch that property to false.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: hide() quits?

    Quote Originally Posted by Everall
    How would you ever do something with your mainwindow if everything is hidden? For instance how would you make it visible again?
    For example using timers or global keybord shortcuts. Or a tray icon (but maybe it is treated as a window too? hmm... dunno).

  12. #12
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: hide() quits?

    For example using timers or global keybord shortcuts
    never thought about that.

    Do you know real world applications that use it?

    Thanks

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hide() quits?

    Quote Originally Posted by Everall
    Do you know real world applications that use it?
    http://yakuake.uv.ro/

  14. #14
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: hide() quits?

    Thanks Jacek

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 22:24
  2. How to hide
    By kjiu in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2009, 12:54
  3. unable to hide combobox or spinbox in toolbar
    By Sandip in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2008, 11:52
  4. QToolBox + resize + hide
    By eleanor in forum Newbie
    Replies: 14
    Last Post: 24th October 2007, 19:41
  5. model/view, can't hide row/col
    By grellsworth in forum Qt Programming
    Replies: 7
    Last Post: 17th September 2007, 14:21

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.