Help us understand the problem. What is going on with this article?

QSpinBox利用で整数専用のLineEdit風

事務作業系のアプリなら必要性あるのでは。
WA_InputMethodEnabled,false は無いとwindowsで難ありなので。
keyPressEventは、del back キーで消去されたように見えて消去されていないからです。

from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtWidgets import QSpinBox

class myIntegerBox(QSpinBox):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter)
        self.setProperty("showGroupSeparator", True)
        self.setAttribute(QtCore.Qt.WA_InputMethodEnabled,False)
        self.setButtonSymbols(QtWidgets.QAbstractSpinBox.NoButtons)

    def keyPressEvent(self,event):
        super().keyPressEvent(event)

        # del back space で0 セット
        if event.key() == QtCore.Qt.Key_Delete:
            self.setValue(0)
        if event.key() == QtCore.Qt.Key_Backspace:
            self.setValue(0)
        if event.key() == QtCore.Qt.Key_Space:
            self.setValue(0)

カーソルの位置などに依然難ありです。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away