Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Program failing at Run time
Luism last edited by
Just starting with Qt and really going through a few tutorials and reading a few books trying to get my skill levels up. Really enjoying it at the moment.
I hit a problem on an example program that I am failing to resolve...
This is an exercise from a book i am reading. Instead of just downloading the source code for the problem I'm actually writing the program as I go along. I already had to correct some issues on it to do with the windows api access, but now all seems good and builds fine but when I run it, it crashes immediately.
I have now downloaded the source code from their website, corrected the same issues with the api and their program works fine. I then compared their files with mine and I can see any significant differences between them so I am at a loss here.
This is my program files:
The problem is with QLayout as far as I can see it, but I can't really see why. If I include QLayout on mainwindow.cpp, it will build fine but will crash on run time.
I am re-writing the program from scratch but would really like to know what the problem is, as it is driving me up the wall! I would be grateful for some advice.
I dont have any QtCharts so could not run code.
However, i saw u are using a standalone layout and your issues might come from that.
Please read docs on how to use them
Adding layouts are done by right clicking. very rarely by dragging from widget collection.
Its other type of use case.
So i think you crash here ( mainwindow constructor)
As centralWidget DO NOT have a layout and it return NULL.
Check that :)
Luism last edited by
I am definitely missing something here... If I try to insert a layout by right clicking I don't get the same menu as you, the layouts are all greyed out.
I did manage to make it work by dragging a Vertical Layout from the widget collection and then replace
Is this a way it should be done?
Thank you for your help.
-i f I try to insert a layout by right clicking I don't get the same menu as you, the layouts are all greyed out.
You must first place a widget (any) , then its not grey any more. :)
Yes, its a bit tricky. :(
Is not what you want., its a floating layout :)
The right click is the way in most cases.