Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. QtonPi
  4. Qt Raspberry 3 Touchscreen official 7" Qpushbutton pb

Qt Raspberry 3 Touchscreen official 7" Qpushbutton pb

Scheduled Pinned Locked Moved Solved QtonPi
8 Posts 2 Posters 3.0k Views 1 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.
  • J Offline
    J Offline
    JPannetier
    wrote on last edited by
    #1

    Hello everybody,

    I'm sorry for my english, i'm french :)
    I'm writing you because i'm programming on a Raspberry 3 , with touchscreen 7" and Qt Creator 3.2.1 Based on Qt 5.3.2

    My problem is with the QPusbutton.
    It doesn't stop being activated.
    I tried of used the function event but after setSheetStyle doesn't work any more.

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QTouchEvent>
    #include <QDebug>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {

    ui->setupUi(this);
    
    B_Start=false;
    ui->MyButton->setStyleSheet("border-image: url(:/Ressource/Stop_Button.png)");
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }
    bool MainWindow::event(QEvent *event)
    {

    }

    void MainWindow::on_MyButton_clicked()
    {
    qDebug()<<"Button clicked";
    if(!B_Start)
    {
    B_Start=true;
    ui->MyButton->setStyleSheet("border-image: url(:/Ressource/Play_Button.png)");
    }
    else
    {
    B_Start=false;
    ui->MyButton->setStyleSheet("border-image: url(:/Ressource/Stop_Button.png)");
    }

    }

    void MainWindow::on_MyButton_released()
    {

    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Do you mean on_MyButton_clicked is not called anymore or that the image doesn't change ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JPannetier
        wrote on last edited by
        #3

        on_MyButton_clicked is alway called when my finger is on my Button .
        Into my qDebug windows, i have :
        Button clicked
        Button clicked
        Button clicked
        ...
        If i insert a breakpoint on ui->MyButton->setStyleSheet("border-image: url(:/Ressource/Play_Button.png)");
        MyButton change of StyleSheet

        If I delete my function event.
        MyButton doesn't stop to change of StyleSheet and on_MyButton_clicked is called looped

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I missed that you had a custom event method. You should at least call the base class implementation otherwise you are breaking the handling of the events in your MainWindow.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JPannetier
            wrote on last edited by
            #5

            Hello SGaist,

            Thank you for your reply.
            Could you write me a quick example how write a call the base class implementation otherwise ?

            Best regard

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6
              return QMainWindow::event(event);
              

              This is basic C++, so if you are new to that programming language, don't hesitate to state it. It's not a crime and avoid people to assume the wrong level of knowledge when answering to you.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JPannetier
                wrote on last edited by
                #7

                Super .
                I tested ;)
                It's working

                Very thank

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  You're welcome !

                  Since you have it working now, please mark the thread as solved using the "Topic Tools" button so other forum users may know a solution has been found :)

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  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