PDA

View Full Version : Plugin & Designer



fpujol
18th May 2007, 09:48
Hello,

I have a QLabel and QLineEdit that forms part of plugin for a designer. When I use it in a Dialog I don't see the key cursor blink of QLineEdit, here's my code:

akLabelName = new AKLabel(); //inherits from QLabel
akFieldEdit = new AKField(); //inherits from QLineEdit

setFocusPolicy(Qt::StrongFocus);
//akFieldEdit->setFocus();
akFieldEdit->installEventFilter( this );
akFieldEdit->setFocusPolicy( Qt::StrongFocus );
setFocusProxy(akFieldEdit);

QHBoxLayout *qHBoxLayout = new QHBoxLayout();
qHBoxLayout->addWidget(akLabelName);
qHBoxLayout->addWidget(akFieldEdit);

QVBoxLayout *qVBoxLayout = new QVBoxLayout();
qVBoxLayout->addLayout(qHBoxLayout);
setLayout(qVBoxLayout);

marcel
18th May 2007, 09:53
What does eventFilter in your dialog?
I assume that you implemented it since you install the dialog as event filter for the line edit.

marcel
18th May 2007, 10:03
You create those object without a parent. That is the problem.
Add "this" as parent for the label and line edit.

marcel
18th May 2007, 10:03
Therefore, the dialog will not forward any focus events to your widgets.

fpujol
18th May 2007, 10:06
I don't understand you, if I use the Qt Designer and I create a new dialog and I put my plugin and I make a preview when the QlineEdit plugin receives the focus the key cursor don't blink. In Qt Designer there's a similiar plugin in the scratchpad "frame" that is similar to my plugin and his key cursor blink.

wysota
18th May 2007, 10:31
You create those object without a parent. That is the problem.
Add "this" as parent for the label and line edit.
No. Adding widgets to a layout reparents them.


I don't understand you, if I use the Qt Designer and I create a new dialog and I put my plugin and I make a preview when the QlineEdit plugin receives the focus the key cursor don't blink. In Qt Designer there's a similiar plugin in the scratchpad "frame" that is similar to my plugin and his key cursor blink.

Marcel asked you for the event filter. Could we see its code?

marcel
18th May 2007, 10:58
No. Adding widgets to a layout reparents them.Yes, you're right( from QWidget::setLayout ):


if (l->parent() != this) {
l->setParent(this);
l->d_func()->reparentChildWidgets(this);
l->invalidate();
But the layout won't be set if the dialog already has a layout.
This could be the problem. Or the eventFilter.

fpujol
18th May 2007, 11:11
oohhh excuse me my friends I found the problem. I found this methods that some day I use to do a test and then I don't remembered to quit it.

void focusInEvent ( QFocusEvent * event );
void focusOutEvent ( QFocusEvent * event );

Thanks a lot, now I see the key cursor to blink is so nice.