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

QTableView & QSqlTableModel: Erased Default Vertical Header Editing Behavior?



  • Hello all,

    I have a large project where I use a style sheet in my resource file, for a custom QTableView, QSqlTableModel, and QStyledItemDelegate. Now the problem I'm having is the I kind of forgot when I noticed this problem.. When new rows are added before they are submitted, or when a row is changed via the view, the vertical header does not show the ! or the * in the header text. Does anyone know the best way to fix this? I can post any other code that may be relevant to the answer but I believe the problem may be the style sheet (but of course I'm not sure). I didn't do anything fancy. Code for the style sheet below. Thanks for the help :)

    QMainWindow {
        background-color: #FFFFFF;
    }
    
    QWindow {
        background-color: #FFFFFF;
    }
    
    QDialog{
        background-color: #FFFFFF;
    }
    
    QMenu {
        background-color: white;
        color: black;
        padding-left: 3px;
        margin: 2px;
    }
    
    QMenu::item {
        padding-left: 25px;
        padding-right: 15px;
        padding-top: 3px;
        padding-bottom: 3px;
    }
    
    QMenu::item:selected {
        border-color: darkblue;
        color: white;
        background: #567dbc;
        padding-left: 35px;
        padding-right: 15px;
        padding-top: 3px;
        padding-bottom: 3px;
    }
    
    QMenuBar {
        background-color: white;
    }
    
    QMenuBar::item:selected {
        background: #567dbc;
        color: white;
    }
    
    QToolButton::hover {
        background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                    stop: 0 #fafafa, stop: 0.4 #f4f4f4,
                                    stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
    }
    
    QToolButton:pressed {
        color: white;
        background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                stop: 0 #567dbc, stop: 0.4 #CFCFCF,
                                stop: 0.5 #567dbc, stop: 1.0 #CFCFCF);
    }
    
    QTabBar::tab {
        background: white;
        border: 2px solid #C4C4C3;
        border-bottom-color: #C2C7CB;
        border-top-left-radius: 4px;
        border-top-right-radius: 4px;
        min-width: 8ex;
        padding: 2px;
    }
    
    QTabBar::tab:!selected {
        background: #F5F5F5;
        margin-top: 2px; /* make non-selected tabs look smaller */
    }
    
    QHeaderView::section {
        background-color: white;
        color: black;
        padding-left: 4px;
        border: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FFFFFF, stop: 1 #000000);
    }
    
    QHeaderView::section:checked {
        background-color: #ececec;
        border: 1px solid black;
        color: black;
    }
    
    QHeaderView::down-arrow {
        padding-bottom: 2px;
        image: url(:/images/icons/png/079-sortdown.png); width: 18px; height:14px; subcontrol-position: bottom right;
    }
    
    QHeaderView::up-arrow {
        padding-bottom: 2px;
        image: url(:/images/icons/png/079-sortup.png); subcontrol-position: bottom right;
    }
    
    QTableView QTableCornerButton::section {
        background: white;
        border: 1px solid qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FFFFFF, stop: 1 #000000);
    }
    
    QTableView::item:selected:active {
        background-color: #567dbc;
        color: #FFFFFF;
    }
    
    QTableView::item:selected:!active {
        background-color: #CFCFCF;
        color: #323232;
    }
    
    QTableView::item:hover:active {
        background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #DCE4F1, stop: 1 #567dbc);
    }
    
    QProgressBar {
        border: 2px solid grey;
        border-radius: 5px;
        text-align: center;
    }
    
    QProgressBar::chunk {
        background-color: #ccccff;
        width: 10px;
        margin: 0.5px;
    }
    

  • Lifetime Qt Champion

    Hi,

    I think the fastest is the classic:

    • don't apply the style sheet
    • check it behaves as expected
    • comment out everything in your style sheet and apply it
    • check again
    • progressively uncomment items in your style sheet
    • check each time you uncomment something

    Not ideal but should get you the answer.



  • It's not the style sheet. :( Thanks for the advice.
    I'm guessing at this point it may be the re implemented delegate??
    I'm just trying to figure out which function handles that... still digging.


  • Lifetime Qt Champion

    Then does it work as expected without the your delegate ?



  • @SGaist
    Hey sorry it's been a while... but I finally got around to testing some stuff. It does not work regardless of style sheet, delegate. I'm thinking it may be the custom QTableView or QSqlTableModel at this point. I'll get there thanks.


Log in to reply