Solved Basic stuff here...
-
QT = core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
Why is this?
Because in Qt4
widgets
was implicit when givinggui
. In Qt5, both modules are separated for smaller libraries.Is this always required?
If you don't need Qt4 compatibility (just use Qt5), you can just write:
QT = core gui widgets
-
@Uberlinc
hi
Also as a note
here you find all samples from that book
https://github.com/mutse/qt5-book-code
convert to work in Qt5.So if u get other issues related to the changes in includes,
you can use that as reference. -
Thanks for this.
I've actually been using this reference:
https://github.com/GaoHongchen/CPPGUIProgrammingWithQt4
.... which is essentially the same.When I can't get my code to go, I compare side-by-side with this to see if I can spot the typo.
It seems that there are some small differences with the latest when compared to the book.I'll persevere.
Many thanks.
-
@Uberlinc
Ok, seems fine too :)
its just that the other link is fixed
so it just compiles in Qt5. including all the pro file -
Ah! An important difference!
I suspect that many of my woes revolve around Qt 5 compatibility so this will be of great help!Thank you once again!
-
Thanks for the Qt 5 code link.
It was helpful, and I went about making changes to match Qt 5 code standard.
However, it would seem that the code is still not working.
I then went about copying and pasting the raw code from the website in case it was a tiny typo that I kept missing.
Again, it gave the same error.(I apologise. I'm struggling here!)
It refuses to recognise the 'buttonBox' variable in spite of:
- Being created in the Design Tool
- Being specified in the Design Tool Property Editor (yes, I checked syntax)
- It is clearly specified in the qmake created ui_gotocell.h file.
- I have ensured that the ui_gotocell.h file is included in the relevant file (and I added it to the .cpp file for good measure!)
It keeps giving the error "buttonBox was not declared in this scope."
I've been staring at it for hours.
Any ideas?
Thanks.
-
Can you provide a link to your specific example?
-
-
@Uberlinc It should be
ui->buttonBox
-
Do you mean:
#include <QtWidgets>
#include "gotocelldialog.h"
#include "ui_gotocelldialog.h"GoToCellDialog::GoToCellDialog(QWidget *parent)
: QDialog(parent)
{
setupUi(this);
Ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}"); lineEdit->setValidator(new QRegExpValidator(regExp, this)); connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
void GoToCellDialog::on_lineEdit_textChanged()
{
Ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
lineEdit->hasAcceptableInput());
}This yielded "Expected Primary Expression before ->"
(as well as the original two errors.)I tried it with a Ui::buttonBox and it gave "buttonBox is not a member of Ui"
Suggestions?
Thanks.
-
Hi
i think something went wrong copying stuff around
I just download the whole zip and open that project.
and it just ran.so could u try try with clean project ?
-
-
I can find the code listings, but not the zip file.
Am I missing it here?
Can you please provide a link?Thanks.
-
-
@jsulm
It uses the old ? / other way with ui
class GoToCellDialog : public QDialog, public Ui::GoToCellDialog
:) -
Okay, yes the downloaded version works.
The only thing that I can think of is that when creating the form, I selected "Dialog" instead of "Widget."
I must have missed that the first time around.Would this have caused this problem?
Thanks.
-
@Uberlinc
well for
"buttonBox was not declared in this scope."
i would guess on something with the UI and maybe left
over files in your build folder.
Using Dialog and not widget should not have changed the name of buttons / if it was created. -
Okay.
I guess this is something that will come easier to me with more experience.
Thank you to all who assisted.I will push on!
-
@Uberlinc
well push on and it will be super :)
Sometimes one needs to clean build folder. ( as in delete all in it)