Results 1 to 12 of 12

Thread: How to turn off this annoying feature of QColumnView?

  1. #1
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to turn off this annoying feature of QColumnView?

    Hi all,

    I use a QStandardItemModel coupled with QColumnView to display a list of simple hierarchal tree structure. My view has 2 columns, rows on the second columns are children of a item on first column. When user select a item/row on column 1, children of that item/row will be displayed on second column. Now here comes the annoying behavior of the QColumnView: although my list has only 2 columns, whenever user click on an item of the second column, it automatically rolls further to the third column on the right (which is empty).

    How do I disable this annoyed feature so that even if user click on a row in second column, the view does not automatically roll horizontally?

    Thank you for all your help.
    Sincerely,

    Wieland J.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to turn off this annoying feature of QColumnView?

    Try reimplementing QColumnView::createColumn() and returning 0. But in general it might be easier for you to substitute the column view with two list views. After all, the column view is for something different...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2009
    Posts
    51
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to turn off this annoying feature of QColumnView?

    Thanks Wysota. That what I will do (using 2 lists). BTW, Could you elaborate on what QColumnView is intended for?
    Sincerely,

    Wieland J.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to turn off this annoying feature of QColumnView?

    It's a widget originating on Mac for showing filesystem contents. The final column is meant to show a preview of a node (file) chosen in the previous column.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5

    Default Re: How to turn off this annoying feature of QColumnView?

    I attempted to do exactly this....and it dies on me.

    Qt Code:
    1. namespace systemoutliner
    2. {
    3. class MyColumnView : public QColumnView
    4. {
    5.  
    6. Q_OBJECT
    7.  
    8. public:
    9.  
    10. MyColumnView(QWidget* parent=NULL);
    11. ~MyColumnView();
    12. protected:
    13. virtual QAbstractItemView * createColumn ( const QModelIndex & index );
    14.  
    15. };
    16. }
    17.  
    18.  
    19. namespace systemoutliner
    20. {
    21. MyColumnView::MyColumnView(QWidget* parent):
    22. QColumnView(parent)
    23. {
    24. }
    25. MyColumnView::~MyColumnView()
    26. {
    27. }
    28.  
    29. QAbstractItemView* MyColumnView::createColumn ( const QModelIndex &)
    30. {
    31. return NULL;
    32. }
    33. }
    To copy to clipboard, switch view to plain text mode 

    And when I try to connect a Model to this view I get this error:

    QObject::connect: Cannot connect (null)::clicked(QModelIndex) to systemoutliner::MyColumnView::_q_clicked(QModelInd ex)
    QObject::connect: Cannot connect (null)::activated(QModelIndex) to systemoutliner::MyColumnView::activated(QModelInde x)
    QObject::connect: Cannot connect (null)::clicked(QModelIndex) to systemoutliner::MyColumnView::clicked(QModelIndex)
    QObject::connect: Cannot connect (null)::doubleClicked(QModelIndex) to systemoutliner::MyColumnView::doubleClicked(QModel Index)
    QObject::connect: Cannot connect (null)::entered(QModelIndex) to systemoutliner::MyColumnView::entered(QModelIndex)
    QObject::connect: Cannot connect (null):ressed(QModelIndex) to systemoutliner::MyColumnView:ressed(QModelIndex)




    Any ideas?

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: How to turn off this annoying feature of QColumnView?

    Your code doesn't show where these connections are made.

  7. #7

    Default Re: How to turn off this annoying feature of QColumnView?

    sorry...

    Qt Code:
    1. MyColumnView *columnView = new MyColumnView();
    2. //QColumnView* columnView = new QColumnView();
    3. ColumnModel *columnModel = new ColumnModel(inspectorGadget);
    4. columnView->setFocusPolicy(Qt::NoFocus);
    5. columnView->setModel(columnModel);
    To copy to clipboard, switch view to plain text mode 

    Line 5 explodes.....

    ColumnModel is my own QAbstractModel class, but it works just fine with the default QColumnview.

    Thanks,
    Larry

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to turn off this annoying feature of QColumnView?

    You still don't show where these connect() calls are being made. The error messages are coming from using a null pointer as the first argument to the connect() calls listed.

  9. #9

    Default Re: How to turn off this annoying feature of QColumnView?

    well.... I didn't write the connect calls that are failing? I'm inheriting from a QAbsractItemModel and I'm overloading a QColumnView.

    None of those pointers are NULL in the debugger when I make that setModel call so I am a bit puzzled. I guess I'll have to compile the Qt libs debug so I can step into them and see where is exploding.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to turn off this annoying feature of QColumnView?

    You are returning a null pointer from QColumnView::createColumn() reimplementation so no wonder you get such messages. You have to return a widget there. You can hide it afterwards if you don't want it but it has to be there.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11

    Default Re: How to turn off this annoying feature of QColumnView?

    Ahhh.....

    That is a bummer since your original suggestion was to return a 0. I have opened the QColumnView.cpp and yeah, its pretty obvious that returning a NULL in that function is going to blow up the world.....

    I'm looking right now, but does anyone have a quick suggestion to turn off the preview column in QColumnView?

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to turn off this annoying feature of QColumnView?

    I have given you a suggestion already. Hide the column.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.