Results 1 to 2 of 2

Thread: setColumnReadOnly and setFocusStyle in qt4 QTableWidget?

  1. #1
    Join Date
    Oct 2007
    Posts
    39
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question setColumnReadOnly and setFocusStyle in qt4 QTableWidget?

    I was using Q3Table. Now I want to use QTableWidget My code was
    Qt Code:
    1. q3Table->setColumnReadOnly(0, true);
    2. q3Table->setColumnReadOnly(2, true);
    3. q3Table->setColumnReadOnly(3, true);
    4. q3Table->setColumnReadOnly(5, true);
    To copy to clipboard, switch view to plain text mode 

    Now I want to port this to qt4 So if I do
    Qt Code:
    1. q4TableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
    To copy to clipboard, switch view to plain text mode 

    All coulmns will be readOnly, so how I should do it?

    Also while porting from qt3 to qt4 i have
    Qt Code:
    1. q3Table->setFocusStyle(Q3Table::FollowStyle);
    To copy to clipboard, switch view to plain text mode 

    Can you suggest me what would be the equivalent code for both ?
    Darshan

  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: setColumnReadOnly and setFocusStyle in qt4 QTableWidget?

    To make an item read only you have to make sure QTableWidgetItem::flags() doesn't return ItemIsEditable or ItemIsEnabled, depending on the effect you want to achieve. You can set the flags for a particular item with QTableWidgetItem::setFlags(). I also suggest to consider switching to a model based approach if you are trying to make something complex.

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.