[Interest] QAbstrctSpinBox position issues

Scott Bloom scott at towel42.com
Tue Feb 24 18:13:03 CET 2026


Using Qt 6.8, I have a dialog that "others" (read customer spec) has been changing a ton. Ive missed a couple of "set the tab order correctly"
when the layout was changed.  So I wrote a simple function to automate the tab order

Essentially, it finds all the children of the widget, sorts by y position then x position, then sets the tab order appropriately.

Ive hit a snag, that makes no sense.

For QAbstractSpinBox derived classes (QDateEdit in particular, but it appears to be for all spin box classes) there are two positions.

First is the pos reported QAbstractSpinBox::pos, and then there is a hidden internal  QLineEdit called "qt_spin_box_lineedit" which has a totally different position reported.

The issue is sometimes the Spin Box's position is correct, other times the line edit's is.

I realize this is an internal widget, so there is likely zero public documentation.  But looking through the code, I can not find any rhyme or reason why the locations are so different.

The work around, is beyond a hack.  I wound up forcing the widget to require each input to have a buddy label.   This allows me to determine the Y location (note the X is fine) by

  1.  Checking if it has a buddy label, if so use its Y
  2.  Checking if the widget has an internal widget, if so use its Y
  3.  Finally use the actual Y position of the widget

Any thoughts on this?  I realize I'm missing a sample, I can create one and will if I wind up filing a bug on this, for now Im just wondering if anyone has seen this before and has any thoughts.

Scott



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20260224/4efa4a01/attachment.htm>


More information about the Interest mailing list