vegeta1in
28th December 2017, 22:46
Hi,
I have a pushbutton widget on a window and Auto repeat is enabled for that pushbutton.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManualModes</class>
<widget class="QMainWindow" name="ManualModes">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<height>287</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(40, 40, 40);</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="M_Spot_Up">
<property name="geometry">
<rect>
<x>210</x>
<y>2</y>
<width>55</width>
<height>40</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/resources/resources/other/button_arrow_up_off1.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>55</width>
<height>40</height>
</size>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>10</number>
</property>
<property name="autoRepeatInterval">
<number>50</number>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Now I have Slots for pressed and released as follows:
void ManualModes::on_M_Spot_Up_pressed()
{
bool res = false;
if(Status.ReadyForMB)
{
qDebug()<<"Spot Up Pressed";
if(this->inAction != true)
{
ui->M_Spot_Up->setStyleSheet(QString::fromUtf8 ("QPushButton {border-image: url(:/resources/resources/other/button_arrow_up_on1.png);}"));
this->inAction = true;
}
res = sendDataPacket(P_BackSpotUp,true);
if(!res)
{
qDebug() << "P_BackSpotUp Packet sent fail";
}
}
}
void ManualModes::on_M_Spot_Up_released()
{
if(Status.ReadyForMB)
{
qDebug()<<"Spot Up Released";
this->inAction = false;
ui->M_Spot_Up->setStyleSheet(QString::fromUtf8 ("QPushButton {border-image: url(:/resources/resources/other/button_arrow_up_off1.png);}"));
}
}
My Intention,Over here Is When I press the button and hold(touchscreen), It should be invoking on_M_Spot_Up_pressed continuously with auto repeat interval. And when I release the button It should invoke on_M_Spot_Up_released.
But In my code, When I press and Hold I am seeing both pressed and released called continuously instead of only pressed.
Debug Output:
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Any Help how to resolve this problem on this push button widget.
I have a pushbutton widget on a window and Auto repeat is enabled for that pushbutton.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ManualModes</class>
<widget class="QMainWindow" name="ManualModes">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>272</width>
<height>287</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<property name="styleSheet">
<string notr="true">background-color: rgb(40, 40, 40);</string>
</property>
<widget class="QWidget" name="centralwidget">
<widget class="QPushButton" name="M_Spot_Up">
<property name="geometry">
<rect>
<x>210</x>
<y>2</y>
<width>55</width>
<height>40</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/resources/resources/other/button_arrow_up_off1.png);</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>55</width>
<height>40</height>
</size>
</property>
<property name="autoRepeat">
<bool>true</bool>
</property>
<property name="autoRepeatDelay">
<number>10</number>
</property>
<property name="autoRepeatInterval">
<number>50</number>
</property>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Now I have Slots for pressed and released as follows:
void ManualModes::on_M_Spot_Up_pressed()
{
bool res = false;
if(Status.ReadyForMB)
{
qDebug()<<"Spot Up Pressed";
if(this->inAction != true)
{
ui->M_Spot_Up->setStyleSheet(QString::fromUtf8 ("QPushButton {border-image: url(:/resources/resources/other/button_arrow_up_on1.png);}"));
this->inAction = true;
}
res = sendDataPacket(P_BackSpotUp,true);
if(!res)
{
qDebug() << "P_BackSpotUp Packet sent fail";
}
}
}
void ManualModes::on_M_Spot_Up_released()
{
if(Status.ReadyForMB)
{
qDebug()<<"Spot Up Released";
this->inAction = false;
ui->M_Spot_Up->setStyleSheet(QString::fromUtf8 ("QPushButton {border-image: url(:/resources/resources/other/button_arrow_up_off1.png);}"));
}
}
My Intention,Over here Is When I press the button and hold(touchscreen), It should be invoking on_M_Spot_Up_pressed continuously with auto repeat interval. And when I release the button It should invoke on_M_Spot_Up_released.
But In my code, When I press and Hold I am seeing both pressed and released called continuously instead of only pressed.
Debug Output:
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Spot Up Pressed
Spot Up Released
Any Help how to resolve this problem on this push button widget.