My app only displays the exit button:(
-
I'm newbie in creating applications, I love Qt. My problem is I don't know the why only the exit button pop up even if there is no error said in the issues tab:(
I hope you can help for my project, my teacher did not teach us how to do this, she just give us this task without worrying if we can do it or not. I just self learned , lease help me, I want to be a programmer so bad.
-
@NewBieBoy
You do not use layouts: you need to use a layout and add your widgets onto that. Because you add the widgets directly onto the main window with no layouts you will find that all 3 of your widgets are piled up underneath the last one, theExit
one, and that is why that is the only one you see. -
-
Btw: If this is an assignment from school which your teacher gave to you, the "template" is probably from your teacher as well?!
The comment (made by her?!) in your second screenshot litterally saysLayout setup and window design can be added here
.
Also better post code using a code section (Button</>
), so that is formatted as such and people dont have to check images for code :) -
@Pl45m4 Aww sorry for that, the truth is the code is from chat gpt, since I've no one to ask to, my buddy is just the gpt, I am planning to have at least one output because the deadline is near, chat gpt explains the code so that I can understand it..
Since the deadline is near, my plan is have an output, study how this works, then submit it to my teacher. Then after that I'll continue to learn to fully understand how the QT codes works.
-
well as specified in earlier comments. use layouts to organize your child widgets in specific order. if you want your widgets to be floating (to place your widgets in specific location use .move()) then your code does that.
however you can force widget to be shown using .show(); method.
i.e
sign_in_button.show();
but i am not sure if this is great advice.
-
@starkm42 said in My app only displays the exit button:(:
i think all your buttons are on top of each other :).
That's what @JonB said :)
@NewBieBoy said in My app only displays the exit button:(:
the code is from chat gpt
Ok, but then the same applies: ChatGPT probably took it from somewhere as a template, where also these comments were made, so that you can (should) fill in your own custom code and add layouts and other stuff.
The source must have been also kinda old since it's using the outdated connection style (string based withSIGNAL
andSLOT
keywords instead of function pointers).
@JonB you "missed" your chance to complain about your favourite topic ;-PNo, serious @NewBieBoy, if you start all over new with Qt, learn and get used to the most recent syntax, which was already introduced quite some time ago. But you will still come across lots of projects which use the one as in your current project.
-
@Pl45m4 @Pl45m4 thank you!, I've finally made it, I used stackedwidgets and setCurrentIndex to create page and navigate to other page..
My app runs now.
My next problem is that how can I export it to executable file, I have never tried it before😕```
![pic.png](https://ddgobkiprc33d.cloudfront.net/45d2a4df-8f5a-44ba-b4cd-dc964300f856.png)
-
@NewBieBoy said in My app only displays the exit button:(:
My next problem is that how can I export it to executable file, I have never tried it before😕
Just check your "build" folder... how it's named, where it's located and other things depend on your settings.
Every time you start your program in QtCreator, it builds/compiles your code and executes it.
The executable should be in your project directory inbuild/Debug
orbuild/Release
or whatever config. you are currently running.To use it stand-alone (I guess that's what you thought of) you have to deploy it properly
Therefore check: