[Interest] QComboBox inside in QTableWidget: How to disable mouse scrolling of QComboBox?

Muthulingam Ammaiappan muthulingam.a at gmail.com
Tue Feb 7 11:27:50 CET 2012


Hi Jaco,

here i am not using QTableView ... i have the TableWidget class which is
derived from "QTableWidget"... and i have implemented the eventFilter in
TableWidget class...?

let me know,what i is wrong with the eventFilter which i have implemented??

Thanks & Regards,
Muthu



On Tue, Feb 7, 2012 at 3:53 PM, Jaco Naude <naude.jaco at gmail.com> wrote:

> I think you must install the eventFilter on the viewport() of the table
> view.
> Did not test, it just a quick quess.
>
> On Tue, Feb 7, 2012 at 11:59 AM, Muthulingam Ammaiappan <
> muthulingam.a at gmail.com> wrote:
>
>> Hi Friends,
>>
>> I have QTableWidget... it has "QComboBox" as a cellWidget in one of it
>> column...
>>
>> I wanted to disable the ScrollEvent of QComboBox... so when cursor is on
>> top of the QComboBox ,if user try to do the Mouse Scroll,then it should not
>> change the index....
>>
>> To achieve this, I just implemented the "eventFilter" in TableWidget
>> class.... but still ScrollEvent is working...
>>
>> can anyone please help me to fix this problem...?
>>
>>
>> Thanks & Regards,
>> Muthu
>>
>> code snippet:
>>
>> TableWidget::TableWidget(QWidget *parent, MainWindow *mainwindow)
>>
>>     : QTableWidget(parent)
>>
>> {
>>
>>         versioncombo->setFocusPolicy( Qt::StrongFocus);
>>
>>     versioncombo->installEventFilter( this );
>>
>>  }
>>
>>
>>
>> bool TableWidget::eventFilter(QObject *obj, QEvent *event)
>>
>> {
>>
>>     if(event->type() == QEvent::Wheel &&
>>
>>            qobject_cast<CustomComboBox*>(obj))
>>
>>         {
>>
>>             if(qobject_cast<CustomComboBox*>(obj)->focusPolicy() == Qt::WheelFocus)
>>
>>             {
>>
>>                 event->accept();
>>
>>                 return false;
>>
>>             }
>>
>>             else
>>
>>             {
>>
>>                 event->ignore();
>>
>>                 return true;
>>
>>             }
>>
>>         }
>>
>>         return QWidget::eventFilter(obj, event);
>>
>> }
>>
>>
>>
>>
>> CustomComboBox::CustomComboBox(QWidget *parent)
>>
>>     : QComboBox(parent)
>>
>> {
>>
>>     setEditable (false);
>>
>>     setFocusPolicy(Qt::StrongFocus);
>>
>> }
>>
>>
>>
>> void CustomComboBox::focusInEvent(QFocusEvent*)
>>
>> {
>>
>>      setFocusPolicy(Qt::WheelFocus);
>>
>> }
>>
>>  void CustomComboBox::focusOutEvent(QFocusEvent*)
>>
>> {
>>
>>      setFocusPolicy(Qt::StrongFocus);
>>
>> }
>>
>>
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
>
> --
> Jaco Naude'
>
> Qtilities: Building blocks for Qt applications.
> http://www.qtilities.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120207/38247cec/attachment.html>


More information about the Interest mailing list