Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Windows and Dialogs
I want to have a window with GraphicsView/Scene & menu bar and a window, that pops out first and gather names via Line Edit and pass it further. I don't really need a ui for the first/main one. What widgets best to use and where to create?
I've got something like that by now, but due to a massive amount of errors I cannot even run it. However, I can see my ideas. I'm open for big changes.
From what you wrote QInputDialog::getText could be enough.
But that is just one lineEdit-ish a dialog, right? I need more, like in the photos. Is the way I created and run a dialog correct? What can I improve?
@MFrost QInputDialog::getText creates and shows a dialog...
- Is the way I created and run a dialog correct? What can I improve?
If you use exec() there is no need to new the dialog as exec() is blocking.
is fine. No possiblty for leaks and works just as fine.
Maybe you want to check for user pressing Cancel?
Also, naming it Dialog is not super.
InputPlayerNameDialog or anything that describes its role is much better.
MFrost last edited by MFrost
@jsulm Well, what I've tried to say/seek confirmation of is, that this type contains only one input place and I need four different lineEdits.
yes QInputDialog::getText is just a simple dialog.
If you need more, you must make a custom one.
@mrjj This doesn't work:
And this neither(with default dialog):
What is wronq in both cases?
Well you fist connect the signal AFTER
Dialog has been shown and closed :)
Try connect just after you declare it.
What is wrong?
first guess is that
you didnt use the SIGNAL() and SLOT() macros ?
also check the return code from connect.
qDebug() << "test=" << connect ( &dia, SIGNAL( rejected() ), this, SLOT( close()) );
note the & on dia.
so connect is accepted.
So when you press cancel on dialog it should call close on mainwind.
You have made sure in playerNames that you actually use accepted() and rejected() ?
What shoudl I write inside?
in button rejected and button accepted
try call accept() and reject() so dialog is closed in normal faction.
Currently im not 100% sure it will send the signals with your implementation.
(and hence close for mainwin wont be called)