Results 1 to 8 of 8

Thread: QTableView - alignment/selection problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Oct 2009
    Posts
    364
    Thanks
    10
    Thanked 37 Times in 36 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QTableView - alignment/selection problem

    but it goes back to being right aligned once you finish editing - right?

    See if the following works better:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent)
    2. : QMainWindow(parent), ui(new Ui::MainWindowClass)
    3. {
    4. ui->setupUi(this);
    5.  
    6. ui->tw->setColumnCount(4);
    7. ui->tw->setRowCount(4);
    8.  
    9. for(int row=0; row < ui->tw->rowCount(); row++)
    10. {
    11. for(int col=0; col < ui->tw->columnCount(); col++)
    12. {
    13. QTableWidgetItem *twi = new QTableWidgetItem(QString("row%1 col%2").arg(row+1).arg(col+1));
    14. if(col == 2)
    15. twi->setTextAlignment(Qt::AlignRight);
    16. ui->tw->setItem(row,col,twi);
    17.  
    18. }
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    I'm attaching the project just in case.

    hope this helps. I'm also still learning.
    Attached Files Attached Files
    Last edited by schnitzel; 29th November 2009 at 05:19. Reason: updated contents

Similar Threads

  1. QTreeView problem scrolling to end.
    By seneca in forum Qt Programming
    Replies: 7
    Last Post: 22nd December 2015, 12:08
  2. Problem with KeyPress event and QTableView
    By ranna in forum Qt Programming
    Replies: 1
    Last Post: 16th January 2009, 20:01
  3. Replies: 1
    Last Post: 23rd December 2008, 15:42
  4. Multi-line messages in QTableView
    By Conel in forum Qt Programming
    Replies: 6
    Last Post: 13th April 2006, 13:49
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.