Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 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
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 3.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gmatbarua
    wrote on last edited by
    #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.
    Also

    clicked : "4" Digit Value: 4
    clicked : "5" Digit Value: 5
    clicked : "6" Digit Value: 6
    
    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      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,9

      Everything 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

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • G Offline
        G Offline
        gmatbarua
        wrote on last edited by
        #3

        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 Reply Last reply
        0
        • EddyE Offline
          EddyE Offline
          Eddy
          wrote on last edited by
          #4

          (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,

          Qt Certified Specialist
          www.edalsolutions.be

          1 Reply Last reply
          2
          • G Offline
            G Offline
            gmatbarua
            wrote on last edited by gmatbarua
            #5

            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.

            1 Reply Last reply
            0
            • EddyE Offline
              EddyE Offline
              Eddy
              wrote on last edited by
              #6
              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

              Qt Certified Specialist
              www.edalsolutions.be

              1 Reply Last reply
              0
              • G Offline
                G Offline
                gmatbarua
                wrote on last edited by Eddy
                #7

                Google results

                https://stackoverflow.com/questions/32688153/how-to-disable-automatic-mnemonics-in-a-qt-application-on-kde

                https://github.com/GoldenCheetah/GoldenCheetah/wiki/Working-around-KDE-shortcut-injection

                1 Reply Last reply
                0
                • EddyE Offline
                  EddyE Offline
                  Eddy
                  wrote on last edited by Eddy
                  #8

                  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

                  Qt Certified Specialist
                  www.edalsolutions.be

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    gmatbarua
                    wrote on last edited by
                    #9

                    Sir,
                    Which platform to use for Professional development with Qt?

                    1. Latest Kubuntu - stale QT version
                    2. KDE Neon - Latest QT version
                    3. 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.

                    1 Reply Last reply
                    0
                    • EddyE Offline
                      EddyE Offline
                      Eddy
                      wrote on last edited by Eddy
                      #10
                      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

                      Qt Certified Specialist
                      www.edalsolutions.be

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved