Solved The "Calculator" example in Qt Examples->widget->widget->Calculator in 5.8.0 version is not working in Kubuntu 17.04 as well as Manjaro KDE 17.0.1
-
The "Calculator" example in Qt Examples->widget->widget->Calculator in 5.8.0 version is not working in Kubuntu 17.04 as well as Manjaro KDE 17.0.1
In Kubuntu 17.04 and Manjaro KDE 17.0.1 updated
Button class inherited from QToolButton class.
In calculator.cpp class file in line 148
Calculator::digitClicked() { Button *clickedButton = qobject_cast<Button *>(sender()); int digitValue = clickedButton->text().toInt(); // This line was added by me to debug and see the values qDebug() << "clicked : " << clickedButton->text() << " Digit Value: " << clickedButton->text().toInt() << "\n"; if (display->text() == "0" && digitValue == 0.0) return; if (waitingForOperand) { display->clear(); waitingForOperand = false; } display->setText(display->text() + QString::number(digitValue)); qDebug() << "display : " << display->text() << "\n"; }
When I run the code from konsole, the calculator display is not updated and when I press digits, for example 4, then 5, then 6
clicked : "&4" Digit Value: 0 clicked : "&5" Digit Value: 0 clicked : "&6" Digit Value: 0
For other buttons in the calculator for "=", "-", "", "/", the button.text() returns correct QString i.e "=", "-", "", "/" respectively.
In Windows 7
There is no such problem in 32 bit mingw qt version 5.8 in windows 7.
For that the result is updated in calculator display.
Alsoclicked : "4" Digit Value: 4 clicked : "5" Digit Value: 5 clicked : "6" Digit Value: 6
-
Hi gmatbarua,
Welcome to the Qt forum!
I haven't found a Bug report with the same issue. Obviously the text of the buttons changed to i.e.. &2 instead of 2, so the conversion to a number doesn't work.
I've tested it on
Debian Jessie with kde desktop Qt5,9
Mac El capitan Qt5,9Everything is ok there.
Are you sure you didn't alter anything else? Did you make a copy of the project before altering things? If so is it possible to test with the original one? Or copy the one from your windows box to kubuntu.
Eddy
-
Thanks sir for the prompt reply.
I compiled the versions in both Kubuntu 17.04 and Manjaro KDE 17.0.1 for the stock version. After the calculator app display did not update for each click, I added the qDebug() statements. Build it again and ran the executables in Konsole.Two questions still remain:
(1) Why text() function appends & sign arbitrarily.(2) The problem seems to happen in a combination of the following:
KDE 5.9.5
KDE Framework 5.34.0
Qt 5.8.0
What is the KDE version in Debian Jessie you are using? -
(1) since you didn't change the code and I cannot reproduce the same error I would suggest that you debug to the point where the text on the buttons are set. Very strange indeed.
On a side note : how did you install Qt5.8? did you use the online installer or did you compile it from the sources?(2) My Debian 8 "Jessie" uses KDE 4.14.2,
-
Sir,
After the text of the buttons are set, fetching their text returns proper value. When any button is clicked, the text gets changed. I have read somewhere that KDE is interfering with the button shortcuts.
Qt 5.8 is the only present version in the repositories of Kubuntu 17.04 and Manjaro KDE 17.0.1.
-
I have read somewhere that KDE is interfering with the button shortcuts.
Interesting, any idea where you read that?
As a workaround you could install Qt5.9 LTS using the online installer (link)to get a Qt environment without interference. That's how I prefer to do it and it's very easy to update or add/delete modules/options using the maintenance tool.
We can guide you through if you have never been on that path.
Eddy
-
-
Thanks for posting this for future reference.
Did you try the solution provided in those links? If so, please mark this thread as solved by using the Topic tools button on the right.This can be solved by getting rid of the implicit state encodings in button text, or by getting rid of the injected shortcuts by adding [Development] AutoCheckAccelerators=false to ~/.config/kdeglobals
Eddy
-
Sir,
Which platform to use for Professional development with Qt?- Latest Kubuntu - stale QT version
- KDE Neon - Latest QT version
- Manjaro KDE - Latest QT version available in repository of any linux distro available (same as Arch)
If I use the Qt installer in any of these, will it work well with rest of the distro provided ecosystem i.e git, gcc, gdb, etc
Please guide me sir, as I am new to serious/professional development. I am accustomed to C++, Qt, intermiditae level administration of Arch, Manjaro and Ubuntu variants. When I was an arm chair developer/student I had time to fiddle around with computer, but now I want 100% focus on development.
-
If I use the Qt installer in any of these, will it work well with rest of the distro provided ecosystem i.e git, gcc, gdb, etc
On of the tricks I used to do is install the repositories like you did already. This makes that all dependencies are already installed on your system. Then use the online installer.
I have done that with ubuntu kubuntu and debian. I supoose the others would work as well.Eddy