[Qt] Request to add clipboard operation messages

Luiz Americo Pereira Camara luizmed at oi.com.br
Thu Oct 13 16:13:10 CEST 2011


On 13/10/2011 10:38, zeljko wrote:
>
> On Thursday 13 of October 2011 15:17:09 Luiz Americo Pereira Camara wrote:
>
> > On 13/10/2011 09:40, zeljko wrote:
>
> > > 2nd: you want to abort standard clipboard ops over text controls like
>
> > > QLineEdit by intercepting widgetset ? If yes then I don't know level
>
> > > of complications about this.
>
> > >
>
> > > Qt have default actions menu over such controls (QLineEdit, QTextEdit
>
> > > .. and others where QLineEdit or QTextEdit are inherited, like
>
> > > QComboBox, QSpinBox etc), so basically QEvent::Action/QEvent::Shortcut
>
> > > have to be intercepted and stopped if LCL wants so ... but I'm not
>
> > > sure if this will work ... must dig into qt code to see how is this
>
> > > implemented.
>
> >
>
> > [ sorry zeljko, somehow Thunderbird "Send to List" got confused]
>
> >
>
> > It's not difficult nor requires much code, since Qt maps those actions
>
> > to, e.g., QLineEdit:paste (i looked the callstack when context menu is
>
> > used). Just do in c++ qt wrapper (pascalized code)
>
> >
>
> > procedure QExLineEdit.paste; //override QLineEdit.paste
>
> > var
>
> > AnEvent: QEvent;
>
> > begin
>
> > AnEvent := QEvent.Create(QtPaste);
>
> > if not eventFilter(self, AnEvent) then
>
> > inherited paste;
>
> > end;
>
> >
>
> >
>
> > With this:
>
> > 1) Qt WidgetSet will be notified before the text is changed
>
> > 2) if the event is filtered no text is changed
>
> >
>
> > If this does not work no need to more complicated trials. Only item 01
>
> > is required.
>
>
> No, that cannot work. You cannot override C++ class in pascal, for 
> your needs we need overrided QLineEdit in QtPas4 C library (eg. 
> QLCLLineEdit), but I'm against it.
>

I said "Just do in c++ qt wrapper"

I'm not saying to override in pascal (i just used pascal like language 
because i dont know how c++ inherited call works). I'm proposing to 
override in C++ wrapper. Most specifically in qlineedit_c.cpp.

After implementing the descendant (QExLineEdit) overriding paste, cut, 
clear, copy the only change required would be the below. No more 
changes. The same would apply to QTextEdit

C_EXPORT QLineEditH QLineEdit_create(QWidgetH parent)
{
     return (QLineEditH) new QExLineEdit((QWidget*)parent);
}


> Also another problem raises with QLineEdit members of 
> QComboBOx,QSpinBox and others, all of them must be overrided with 
> QLCLLineEdit in that case.
>
>

No need to do that changes in pascal side. Also no need to add 
TExQtLineEdit.

Just add the message constants (QEventPaste etc) and handle the 
messages/events in TQtLineEdit.EventFilter

> As I said, I'll try to intercept actions (since there it can be 
> stopped), if that won't work then we must change bindings.
>

Ok. Let me know when you get something

Luiz




More information about the Qt mailing list