Expand Top Item in QTreeWidget using QKeyEvent
This code snippet checks if the parent of the current item in the "treewgt" (a QTreeWidget) is NULL and if the top item in the tree widget is not expanded. If both conditions are true, it creates a QKeyEvent object "keyPress" with the key code Qt::Key_Right and no modifier, and sends this event to the "nowWgt" widget using the "QApplication::sendEvent()" function. This simulates a key press event of the right arrow key to expand the top item in the tree widget.
原文地址: https://www.cveoy.top/t/topic/pKHD 著作权归作者所有。请勿转载和采集!