Results 1 to 4 of 4

Thread: QTableView and problems with align

  1. #1
    Join Date
    Sep 2007
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTableView and problems with align

    Hello,

    I have QTableView and i fill it with checkbox widget's.
    Qt Code:
    1. QCheckBox editor = new QCheckBox();
    2. tableView->setIndexWidget (index,editor); //index is QModelIndex();
    To copy to clipboard, switch view to plain text mode 
    But widgets are alignment to right side. I want alignment to middle.

    How can I set this?

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView and problems with align

    I highly recommend you to get rid of expensive index widgets and make the items checkable instead. This is done by returning Qt::ItemIsUserCheckable amongst other flags in your model's flags() implementation. You can adjust text alignment by returning a suitable value for Qt::TextAlignmentRole in model's data() implementation.
    J-P Nurmi

  3. #3
    Join Date
    Sep 2007
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableView and problems with align

    I did that by adding widget to layout, and for layout set TextAligment flag.. It works..

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTableView and problems with align

    Just be aware that Qt's model-view framework has built-in support for checkable items. It is considered as a mistake to abuse QComboBoxes for that. The view has put quite a lot of effort to keeping index widgets in correct places, over corresponding items. I hope you don't have too many items because it will be a resource hog..
    J-P Nurmi

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.