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

后端 未结 1 1675
长情又很酷
长情又很酷 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 <QtGui/QApplication>
    #include <QtGui/QColumnView>
    #include <QtGui/QPushButton>
    #include <QtGui/QFileSystemModel>
    
    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)
提交回复
热议问题