Unsolved Trouble implementing back end functionality to UI
-
I've coded the UI and have it set up as attached at the bottom of the post, and I was wondering how I'd go about implementing my prewritten back end code to the UI. I don't know how storing form information would work and how variables work. Any pointers to where to go next?
I have basic knowledge of signals and slots but I'm not sure where to go with it.
-
Im thinking that this is the way to go. The next button should have multiple connections that sets the inputs to their respective variables all at once when clicked
i.e.QObject::connect(nextButton, SIGNAL(clicked(bool)), nameInput, SLOT(nameInput = nameLineEdit)); QObject::connect(nextButton, SIGNAL(clicked(bool)), heightInput, SLOT(heightInput = heightBox)); QObject::connect(nextButton, SIGNAL(clicked(bool)), widthInput, SLOT(widthInput = widthBox)); etc
Either way, my knowledge of how to set and instantiate these variables, and then manipulate them in Qt is lacking at the moment.
Manipulating them would probably require plugging them all into a function which I also don't know how to do with Qt.
-
Hi and welcome to devnet,
What is the workflow of your application ? Currently it looks like a QWizard.
-
@SGaist
Thanks for the welcome!
I actually currently only have this page built as a series of widgets in a QTabWidget. I feel like if I were to progress forward, it'd probably need to be reimplemented into a QWizard right? -
@bdandans
Hi
Its unclear to me what you are really asking ?To save the values before going to next page,
you can simply take them via the UI ?
(pseudo code)
QString name = ui->nameWidget->text()
QDateTime date= ui->TimeDateWidget->?
int Height = ui->heightWidget->Text().toInt();
....Also if this really is a Wizard Design, then using QWizard as @SGaist
suggest - might save u time.( QStackedWidget also very good for pages)
-
@mrjj said in Trouble implementing back end functionality to UI:
So for example, when you write
QString name = nameEdit->text();
Doesn't that set it to whatever's in the box at the time, which is nothing initially?
How do I make that assignment once the user has finished filling the form?
-
@bdandans said in Trouble implementing back end functionality to UI:
Doesn't that set it to whatever's in the box at the time, which is nothing initially?
Yes, what else should it set? Just do it when it is needed (for example when the user clicks Next button).
How do I make that assignment once the user has finished filling the form?
Connect a slot to the Next button and do it there.
From your first post:
QObject::connect(nextButton, SIGNAL(clicked(bool)), nameInput, SLOT(nameInput = nameLineEdit)); QObject::connect(nextButton, SIGNAL(clicked(bool)), heightInput, SLOT(heightInput = heightBox)); QObject::connect(nextButton, SIGNAL(clicked(bool)), widthInput, SLOT(widthInput = widthBox));
this is invalid code. Please read http://doc.qt.io/qt-5.9/signalsandslots.html
It should look like this:QObject::connect(nextButton, SIGNAL(clicked(bool)), this, SLOT(nextClicked())); void MainWindow::nextClicked() { // Read here the values }