m_pagesEdit->setMaximumWidth(fm.width(QString::number(m_document->pages()))+2*style()->pixelMetric(QStyle::PM_DefaultFrameWidth,&option,m_pagesEdit)+4);// the 4 comes from 2*horizontalMargin, horizontalMargin being a define in qlineedit.cpp
m_pagesEdit->setMaximumWidth(fm.horizontalAdvance(QString::number(m_document->pages()))+2*style()->pixelMetric(QStyle::PM_DefaultFrameWidth,&option,m_pagesEdit)+4);// the 4 comes from 2*horizontalMargin, horizontalMargin being a define in qlineedit.cpp