Opening projects and getting started
-
@Bryan-Kelly
You can certainly design a dialog in Creator/Designer, just like you did for yourMainWindow
. The steps @sierdzio wrote are exactly what you need to do. Saying "The steps noted by @sierdzio did not do the job." does not help know where you had a problem, and your posted code shows no sign of having had a dialog added to it. Onlyquadratic
, which is not a dialog. And I see no sign of aquadratic.ui
being added to your project, just like themainwindow.ui
which shows there. -
@JonB This post had two parts. First, I recognize that what I need may well exceed what is reasonable for a thread. I placed a post in the jobs section here: [link text]([https://forum.qt.io/topic/155638/need-help-with-startup-project-my-qt-first-project?_=1711680558425](link url))
Second, I tried working this and wrote what I did one step at a time. Here is a recap of the goal and the steps that I understand from the posts on how to accomplish those goals. Where did I go wrong? What did I miss?
The goal is to create a simple Qt project with multiple dialogs. Specifically, the main dialog is to have the ability to open additional dialogs. The environment is Windows 11, Qt Creator 12.0.2, and Qt 6.6.0.
I created this in MS Word with numbered lines and indented sub sections. the goal is to prevent a long monolithic description and to provide step numbers that can be referenced when addding advice. I hope the formatting helps some amount.
- File -> New Project
- Create a simple project
a. Application (Qt) -> Qt Widgets Application -> Choose
b. Select your name and location, Next (below "i" is implied indent again)
i. This was named “three_dialogs_02”, the location is defaulted to the same name, noted for possible future use.
c. CMake -> Next
i. Because this beginner does not have sufficient knowledge for any other selection.
d. In dialog Qt Widgets Application, change to suit, but no changes made on this project, Next
e. Translation File -> Next, no changes
f. Kit Selection -> enable Select all kits, because this beginner is now aware better options, Next
g. Project Management -> Finish, no changes
h. Build and run, displays a blank dialog - Create a new dialog, or maybe several
a. File -> New File -> C/C++ -> C++ Class -> Choose
b. In dialog C++ Class, Name it.
i. Just for future reference, the name is quadratic
c. Base Class. There are six options here. Not having a specific reason to change, take the default of <Custom>
d. Not knowing better choices, skip all the options. ??
e. Path: This defaulted to …\three_dialogs_02, left that unchanged -> Next
f. Dialog Project Management, no changes, Finish
g. There are two new files, quadratic.cpp and .h - Provide the ability to open the new dialog
a. Eidt mainwindow.ui
b. Add a Push Button
i. Set its text to: Open Quad
ii. Set its objectName to: pb_open_quad
iii. Right click it and select: Go to slot…
iv. Select QAbstractButton -> clicked -> OK
v. This opens file mainwindows.cpp and has created function:
vi. void MainWindow::on_pb_open_quad_clicked() { }
vii. edit in show() - Build and run
a. the main dialog opens with the new button
b. Click button Open Quad, nothing happens.
c. Close, put breakpoint in new function on_pb_open_quad_clicked() as show():
d. Start debug
e. Click button Open Quad
f. The breakpoint a show() is caught.
g. Press F10 three times and it steps out of the function into moc_mainwindow.cpp
h. Stop here. The pushbutton works, but the new dialog does not.
The new dialog is not shown. There is no new file similar to mainwindows.ui, that represents the new dialog so controls can be added to it in a drag and drop fashion.
Please advise, what did I do in error? What obvious step did I miss? -
@Bryan-Kelly said in Opening projects and getting started:
a. File -> New File -> C/C++ -> C++ Class -> Choose
b. In dialog C++ Class, Name it.This creates a plain C++ class, nothing visual, which is what you ended up with. You are supposed to be creaking a dialog, something like when you designed the main page. @sierdzio wrote:
File->New File->Qt->Qt Designer Form Class.
I'm sure if you went into the Help in Creator it would cover this. I don't necessarily have the same version of Craetor so don't ask me what the wording is, you are supposed to figure this out. Look around the choices of new items available.
-
@JonB I restate my request in different words.
Create a Qt Widgets application.
Under Source Files is the file: mainwindow.ui
When this file is opened the user can drag and drop controls.
Here is the request:
What are the steps to create a new dot ui file into which the user can drag and drop controls? Make the name quadratic.ui -
@Bryan-Kelly
I already answered, and so did @sierdzio . Pick the right new item type to add to the project. Not a plain C++ class, rather a Qt widget. -
@JonB said in Opening projects and getting started:
The question has not been answered. I wrote down the steps one line at a time, posted, and that post was essentially ignored.
After the project is initially created, what steps are needed to use Qt Creator facilities and create the new file quadratic.ui? The dialog is to be such that standard controls, push buttons, text edits, etc, can be dragged and dropped onto it and used in the code.I have searched and have not found the solution. If someone can provide a better search phrase I will use it.
-
@Bryan-Kelly said in Opening projects and getting started:
Qt Creator facilities and create the new file quadratic.ui? The dialog is to be such that standard controls, push buttons, text edits, etc, can be dragged and dropped onto it and used in the code.
Maybe rephrase the above.
In general, forums and this one is no exception, posts gets boggled down in (personal views) , expressions and terminology.You can build application using main window.
You can the add a dialog to it.You can "drag and drop " widget ( user interlace "object" )
into the dialogue DURING construction / coding using the dialog_X.ui file- utilizing QtDesigner tool.This is the way I read / interpret your post
you want the user to be able to "drag and drop" such widget ( from where he get is ?) during RUN TIME.
Is that correct (assumption) ?
-
@AnneRanch said in Opening projects and getting started:
You can the add a dialog to it.
And that is the key phrase.
What are the steps to add the dialog? Let's call the dialog quadratic. To clarify, after adding the dialog I am "expecting" that within "Header Files" there will be the file: quadratic.h Within Source files there will be quadratic.cpp and quadratic.ui (Those names seem logical to me and the exact name is not a requirement.)
When file quadratic.ui is opened for editing, I can drag controls into it, such as push button and line edit. the behavior should be the same as what I find for mainwindow.ui.
This is all during application construction time, not during run time. Then I can add buttons in mainwindow.cpp so that during run time I can open the new dialog and populate fields within the dialog, using appropriate procedures of course.
That one step, adding the dialog, is now the heart of this thread.
-
@Bryan-Kelly said in Opening projects and getting started:
I wrote down the steps one line at a time, posted, and that post was essentially ignored.
And you was told several times already what you need to select to create a dialog (File->New File->Qt->Qt Designer Form Class), instead you wrote:
File -> New File -> C/C++ -> C++ Class -> Choose
As already explained here - this creates a plain C++ class, not a widget/dialog. Why don't you follow advises?
-
@Bryan-Kelly said in Opening projects and getting started:
The question has not been answered. I wrote down the steps one line at a time, posted, and that post was essentially ignored.
You wrote your steps. Far from ignoring you I actually quoted from your own steps, verbatim:
a. File -> New File -> C/C++ -> C++ Class -> Choose
b. In dialog C++ Class, Name it.
See that in the steps you wrote? So how come I quoted your step and what you needed to correct it if I was ignoring you? And then I told you this is wrong. I quoted from @sierdzio who wrote you need to pick:
File->New File->Qt->Qt Designer Form Class.
I also suggested if you go into Creator's help at this point I would have though it would explain the various new item choices available from File -> New File -> C/C++. So you would know which one to pick:
Pick the right new item type to add to the project. Not a plain C++ class, rather a Qt widget.
So, instead of saying your post/question has been ignored why don't you actually follow or respond to my responses? It is simply you who are doing the ignoring. You do not have keep repeating what it is you want to achieve, we all understand that. We know why you are getting it wrong by picking a new "C++ class" as the item, and we have told you that is not the right one to pick, you need to pick the one which offers to create a new Qt widget, which will give you the "surface" where you pick things and drag them onto it to design your widget/dialog.
Note that I use Creator 6. You are using Creator 12. That isa different version from mine. So my screenshots may not match exactly what you see, but hopefully they will be close. Unless you only want screenshots from somebody using the exact same version of Creator as you have.
From Creator, menu File > New File or Project...,
On the left you have C/C++ highlighted and C++ Class selected to the right. The info panel at the right tells you this will add a C++ header and source file to your project. That is what you are picking. This is wrong for what you want. If you pick it you will get the plain C++ class you have had so far. This is not what you want. It is wrong. If you continue with that you will not get what you want. You have to change your choice to the one you need. If you choose to ignore this you will not solve your issue. You have to do something else.
Move your mouse with your hand. In the left hand area move it to the item which says Qt. You want something Qt-specific for designing widgets, so that is what you need to pick.
Now have a look at the choices in the middle. Any of them look possible? What about Qt Designer Form, since you want to create something in Qt Designer and if you read earlier you have been told repeatedly to pick this. Click on Qt Designer Form with your mouse. Then move your mouse to the Choose... button in the bottom right of this dialog and press the mouse to click.
From then on as you work through the wizard hopefully you can make your own choices for what you want. Take the time to look at the choices before you pick one.
Is that enough for you, or still not clear enough? Do you still think I am ignoring your question? Did we not say from the outset that you needed a new Designer form? In all the years I have been here nobody has had any trouble picking a new Designer form to add or asked about it.
-
OK, you "experts"
...cut it out...
The way you are getting into "advices" is too familiar to me.
Stick with technology and STOP the innuendos.
You can help and be more constrictive by skipping the lecturing, unless you have background in teaching.I would actually like to see a Qt published example of the task the OP is trying to do - main application ( main window) with dialog as sub window.
Unfortunately I have not found one yet.
What the OP is trying REALLY needs a solid foundation, mainly because his vision of manipulating the dialog and communicating between main and dialoog , is the VISIBLE part of the iceberg and without good knowledge what " lays hidden in water part ", it does not look much fun to code.
PS
I am using "simple terminal" Qt example , it has similar layout (main window with dialogs ) , but I would not recommend that as first Qt project.PPS
OP - take a look at thishttps://stackoverflow.com/questions/50329211/qt-open-dialog-from-main-window
-
@AnneRanch
The OP is asking how to design a dialog in Creator/Designer, not how to open one once he has it per your link. That requires him to pick Qt Designer Form as the item to create, not the C++ Class he has been picking so far. We have told him this, and my last post shows him it in pictures. Cannot be clearer or more helpful than that. -
@AnneRanch It's OK. I just believe/hope that if the OP looks at the pictures I have posted they will be able to get into the Designer correctly as they want to.
-
@Bryan-Kelly My (final) advise depends if you are planing to USE Qt in the future.
I would actually start my Qt coding using " (simple) terminal" example. .
It is scarcely documented and not very intuitive.
BUT
it puts more "bells and whistles " into code and than it may get frustrating to follow.
BUT
it is main with dialogs !It is a "template / skeleton " of the application, it is all there , and it actually includes "connect" - and that is you goal.
Then you have (two) ways - build each part of the project piece by piece - main, dialog, communication etc
or
reuse what somebody already have done and trace each build part flow and modify it for your purpose.
-
@AnneRanch AnneRanch Suggested using a simple terminal example. I am moving towards the point of thinking that despite my opinion, presumption?, there is no method to utilize drag and drop to create multiple dialogs. If that turns out to be the case I will be rather disappointed in Qt.
I am also confident that I am using Qt Creator 12.0.2 and Qt 6.6.0, that no one else in this conversation is using this version, and this creates a problem. Here are some dialog screen captures and maybe it will lead someone to help me find the right path forward.When creating a project, the above is the first screen. The option of the top left of the left panel, then the top item of the center panel seem to be a clear best choice. From here through to the initial project creation I see no option that I perceive as having a bearing on my core question. So I complete the project creation naming it three_dialog_05, the fifth time I have tried this. After the project has been created, the most appropriate screen capture is below.
This is before writing any of my code. This is where I expect/hope to find the ability to add a new dialog. Note file mainwindow.ui. When opened, the user has the ability to drag and drop controls onto the dialog. My first goal is to find a way to get Qt Creator to create a file named, for example, quadratic.ui. When that file is opened by Qt Creator, it will provide the ability to drag and drop controls onto the new dialog.
With the express purpose of keeping this simple: Is there a way to do this in Qt Creator 12.0.2, or in any version of Qt Creator?
I am torn between: A) writing another post taking one of the paths suggested by other replies and B) stopping here to limit the thread to a single question and if the question is NO, then working one of the other paths.
I am going with simplicity, stopping here, and waiting for, essentially, a Yes or No answer.
To each of you, thank you again for your time and patience. -
@Bryan-Kelly said in Opening projects and getting started:
This is where I expect/hope to find the ability to add a new dialog.
It was actually already explained here.
But I will repeat: go to File/New File or Project..., select Qt on the left side, then select Qt Designer Form, in next step you can select a Dialog as template. Don't know how else to explain this. Maybe you should follow the suggestions? -
@jsulm
As you know, I have already said exactly this (as have others), and quoted exactly where in OP's steps they went wrong and what they should have done. To which OP's reply to me wasThe question has not been answered. I wrote down the steps one line at a time, posted, and that post was essentially ignored.
So quoting from their post counts as ignoring them. Even shown a picture of exactly what it looks like, what the OP has erroneously picked and what they should actually pick. All they have to do is follow exactly their steps where they picked "new C++ class" and change it to "new Qt Designer Form" which is what they want. So it's not clear what we can say any more that the OP will try, instead of keep saying that Creator/Designer does not allow them to design with drag & drop onto a form.
-
@jsulm said in Opening projects and getting started:
@Bryan-Kelly said in Opening projects and getting started:
This is where I expect/hope to find the ability to add a new dialog.
It was actually already explained here.
But I will repeat: go to File/New File or Project..., select Qt on the left side, then select Qt Designer Form, in next step you can select a Dialog as template. Don't know how else to explain this. Maybe you should follow the suggestions?Yes, that worked out well. I have no excuse for not recognizing the right method much earlier in this conversation.
So again, to each respondent, thank you for your time and patience. -
@Bryan-Kelly here is no method to utilize drag and drop to create multiple dialogs.
Excuse my English - but - are you in effect saying DRAG AND DROP TO CREATE / DUPLICATE DIALOG PROJECT?
I am not nitpicking on your statement,
but
there is a difference between that and "drag and drop" objects in SAME dialog.Actually even (opening) projects - plural - is little misleading.