Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ModelView programing with Delegate in qt



  • When I create QSpinBox in createEditor() of QStyleItemDelegate class,It displays in side the cell of the QTableview.
    But when I create QDialog in that function,It gets display out side(seperatly).What could be the reason?


  • Lifetime Qt Champion

    @hjohn
    Hi
    A dialog is a windows type and not embeddable as a widget.
    You can just use QWidget as base class and it will work.
    Since you want to put it inside the cell, QDialog is not the right base class.



  • @mrjj yeah thanks..I will try it using QWidgets.


  • Lifetime Qt Champion

    @hjohn
    Hi
    Its just 2 place to change in code then its Qwidget.
    No reason to recreate it all again. very easy to switch.

    In .h
    class mine : public QDialog <<< the actual base

    and in .cpp
    mine::mine(QWidget *parent) : QDialog(parent), << change the call to base for constructor

    maybe #include <QWidgets> instead of QDialog

    Note:
    there is also
    myDialog->setWindowFlags(Qt::Widget)
    after you construct the dialog.
    It might do the same. not tested. though.


Log in to reply