tags:

views:

50

answers:

1

Hi, 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 be relegated to a preview widget. Is it possible to hide this? Ex, something like view.setPreviewWidget( NULL ), although this breaks the program

EDIT : I should clarify that I'd like a way to hide the last column entirely, ie to have the last column in my view be the "leaves" of the model, and to not have a preview space

A: 

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.

andref
Ahh, sorry I should have clarified that I would like to have the preview space not be visible at all. This does hide the button, but leaves a blank column.
You want the remaining columns to be stretched and occupy the space left by the preview widget?
andref
Ahh yes, that's exactly what I want, how would I go about doing that?