Qt Raspberry 3 Touchscreen official 7" Qpushbutton pb
-
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.2My 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()
{}
-
Hi and welcome to devnet,
Do you mean on_MyButton_clicked is not called anymore or that the image doesn't change ?
-
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 StyleSheetIf I delete my function event.
MyButton doesn't stop to change of StyleSheet and on_MyButton_clicked is called looped -
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.
-
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
-
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.
-
Super .
I tested ;)
It's workingVery thank
-
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 :)