Is it possible to remove the preview widget from a qt QColumnView?

后端 未结 1 1667
长情又很酷
长情又很酷 2021-02-09 05:05

I need to display a hierarchical set of data in a qt view. I\'m using QColumnView to display the model. However, there is a feature such that the last column in the view will

1条回答
  •  孤城傲影
    2021-02-09 05:49

    This will hide the button when it is clicked.

    #include 
    #include 
    #include 
    #include 
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QColumnView view;
        QFileSystemModel model;
        QPushButton button(&view);
    
        button.setText("Click me");
        QObject::connect(&button, SIGNAL(clicked()), &button, SLOT(hide()));
    
        model.setRootPath("/");
    
        view.setModel(&model);
        view.setPreviewWidget(&button);
        view.show();
    
        return a.exec();
    }
    

    Notice that it will become hidden forever. You have to call show() if you want it to be displayed again.

    0 讨论(0)
提交回复
热议问题