QMessageBox closes application
-
@hobbyProgrammer
@jsulm will know better than I, but I wouldn't have thoughtconnect()
would even callprocessEvents()
/the main event loop? -
@hobbyProgrammer Does it crash if you do not connect the slot?
And it would be helpful if you would post the stack trace after crash. -
@hobbyProgrammer said in connect() keeps crashing:
Whenever I use the debugger I don't even get the showContexyMenu(),
So what's the backtrace?
-
I'm not really familliar with the debugger... Does this provide the information you need?
-
@hobbyProgrammer If you post screen shots you should at least make sure the function signature on the bottom-right side are readable...
-
@hobbyProgrammer
It would be better if we could read the full function signatures at the bottom right, instead of left-truncated! Can't you drag the column resizer so we can see the full function name? You can make columns like Condition or Ignore much smaller. -
@hobbyProgrammer said in connect() keeps crashing:
qv.at(i)
It looks like you've created your vector on stack. What exactly does your slot do? Which vars do you access / try to access there?
If the connection fails, you would get an explicit warning / error message (which is obviously not the case)I'm sure, that it crashes because you did something wrong before or inside your slot function.
-
@Pl45m4 Hi, I've found why it closes the app (sort of).
I have a few screens before this one. After going through those screens, you'll end up at this screen.
Whenever I only open this screen, it works perfectly, but when I open the screen through a different screen, it closes after a certain action.
Those other screens are hidden whenever a new screen is shown.I still don't know why it closes.
-
@hobbyProgrammer said in connect() keeps crashing:
I've found why it closes the app (sort of).
@hobbyProgrammer said in connect() keeps crashing:
I still don't know why it closes
Hm.... :D
@hobbyProgrammer said in connect() keeps crashing:
I have a few screens before this one
What kind of screens? You mean, if you are doing something, then it works but if you do something else (different action), then it crashes?
YOU programmed it, so you must know (should know) best, WHAT you did ;-)
Anybody else can just guess, if you make vague descriptions...What does the "crash" look like? Any exception / error message or is it just terminating your process?
-
@Pl45m4 No there's a screen with a "start" button and when you press that button, the graphicsview screen shows up. When I remove that screen it works, but I need that screen/window for the end result.
The way I call a new screen is like this:
In the .h file:
#include "window.h" private: Window *win;
In the .cpp file:
this->hide(); //hides the current screen win = new Window(this); win->show();
-
Using the correct Qt terminology would help too. Sure, it's a kind of "screen" what you see in from of you but if you write
QDialog
or `Q(Main-)Window, everybody can imagine what your program procedure looks like.@hobbyProgrammer said in connect() keeps crashing:
The way I call a new screen is like this:
In the .h file:
#include "window.h"private:
Window *win;In the .cpp file:
this->hide(); //hides the current screen
win = new Window(this);
win->show();This doesn't seem to help for solving your problem ;-) It helps to understand what you are doing. Otherwise we get all the information in pieces and that makes it unnecessarily complicated...
@hobbyProgrammer said in connect() keeps crashing:
When I remove that screen it works
"Remove screen" = Remove / comment the actual code
or
"remove" = dont open that result window?@hobbyProgrammer said in connect() keeps crashing:
In the .cpp file:
this->hide(); // Check if it crashes / exits here win = new Window(this); win->show();
-
@Pl45m4 said in connect() keeps crashing:
"Remove screen" = Remove / comment the actual code
or
"remove" = dont open that result window?Don't open the window.
Whenever I call that second window in the main.cpp it works fine, but when I call the first window in the main.cpp and call the second window in the first window, it has that problem of closing the app on certain actions. -
@Pl45m4 yes it seems to do that. Whenever I open it in the debugger, it gives a blank window with the title "mainwindow" , which is not the title the other window has. However, when I just run it (not in debugger mode) it opens the screen perfectly (apart from that it closes on some actions)
-
What Qt version do you use?
-
@Christian-Ehrlicher 5.12.3. Would upgrading it to 5.13 help?
-
So your connect does not crash - simply your mainwindow does not show up the contents again after hide/show. If so please upgrade to 5.12.5 (and update your thread title - it's completely confusing), there was a bug in the window handling code in 5.12.3 (afair fixed in 5.12.4).
-
@Christian-Ehrlicher yes that seems to be the problem when I run it in debug mode, but when I run it normally it closes the second window after certain actions.
I'm currently upgrading it to 5.12.5, so hopefully this will solve the issue.UPDATE: this did not work for the closing part, but it did resolve the thing in the debugger mode where I would just see a blank window.