Pergunta

I have implemented an OSGQt based model viewer. I am currently attempting to reposition submodels by changing their properties in a child QFrame to the main MainWindow based viewer frame. The child frame is non-modal and the key events are being passed to the OSG Viewer based handler in the MainWindow instead of the child window.

What would be the appropriate attributes for the child window to keep the keyboard focus there and allow typing new values in the QLineEdit based modifier for the QTreeWidgetItem column.

Model layer positioning

Foi útil?

Solução

I have implemented a working solution by using a custom ItemDelegate as follows.

class DoublePositionEditDelegate: public QStyledItemDelegate {
    public:
      DoublePositionEditDelegate(QObject* parent=0): QStyledItemDelegate(parent) {}
      virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const {
          QDoubleSpinBox* dspinbox = new QDoubleSpinBox(parent);
          dspinbox->setMaximum(1000000.0);
          dspinbox->setMinimum(-1000000.0);
          dspinbox->grabKeyboard();
          return dspinbox;
      }
    };

A more elegant/better solution is still welcome.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top