Element info widget : set focus to the first line edit

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3807 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2015-03-05 10:26:09 +00:00
parent af54df2983
commit 8a4efc7fc1
4 changed files with 48 additions and 1 deletions

View File

@@ -33,7 +33,8 @@ ElementInfoWidget::ElementInfoWidget(Element *elmt, QWidget *parent) :
QWidget(parent),
ui(new Ui::ElementInfoWidget),
element_(elmt),
elmt_info(elmt->elementInformations())
elmt_info(elmt->elementInformations()),
m_first_activation (true)
{
ui->setupUi(this);
buildInterface();
@@ -89,6 +90,27 @@ QUndoCommand* ElementInfoWidget::associatedUndo() const {
return nullptr;
}
/**
* @brief ElementInfoWidget::event
* Reimplemented from QWidget::event
* Only give focus to the first line edit at first activation.
* After send the event to QWidget.
* @param event
* @return
*/
bool ElementInfoWidget::event(QEvent *event)
{
if (m_first_activation)
{
if (event -> type() == QEvent::WindowActivate || event -> type() == QEvent::Show)
{
QTimer::singleShot(250, this, SLOT(firstActivated()));
m_first_activation = false;
}
}
return(QWidget::event(event));
}
/**
* @brief ElementInfoWidget::buildInterface
* Build the widget
@@ -122,3 +144,12 @@ void ElementInfoWidget::fillInfo() {
eipw->setHideShow(true);
}
}
/**
* @brief ElementInfoWidget::firstActivated
* Slot activated when this widget is show.
* Set the focus to the first line edit provided by this widget
*/
void ElementInfoWidget::firstActivated() {
eipw_list.first() -> setFocusTolineEdit();
}