Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to add coustem widget to QTableView Model
Forum Updated to NodeBB v4.3 + New Features

How to add coustem widget to QTableView Model

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 3.9k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AmrCoderA Offline
    AmrCoderA Offline
    AmrCoder
    wrote on last edited by AmrCoder
    #1

    I having a QTableView in my project i use QStandardItemModel to make the table and set this model to the QTableView
    i use this code to make the table

    QStandardItemModel *model = new QStandardItemModel();
    

    then I start to add items using QStandardItem, I have a column which is called statue which I want to add in it a spinner progress bar to all the rows in this columns
    so I use this code to add it also i use it after set the model

        SpinnerProgressBar bar = new SpinnerProgressBar();
        ui->tableView->setIndexWidget(ui->tableView->model()->index(i, 3), bar );
    

    i use it in a loop so i can loop on all the table and add the progress bar to each row the problem here is when I use this code it add the spinner progress bar widget in front of the table not in each cell if I use the QPushButton for example or any Qt widget it works fine so what makes this problem happened what mistake I make here
    Update
    i got the spinner widget from an open source project here
    Thanks in advance

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      its because its a dialog.

      WaitingSpinnerWidget::WaitingSpinnerWidget(Qt::WindowModality modality,
                                                 QWidget *parent,
                                                 bool centerOnParent,
                                                 bool disableParentWhenSpinning)
          : QWidget(parent, Qt::Dialog | Qt::FramelessWindowHint),
      

      You can try
      SpinnerProgressBar bar = new SpinnerProgressBar();
      bar->setWindowFlags(Qt::Widget);
      ui->tableView->setIndexWidget(ui->tableView->model()->index(i, 3), bar );

      1 Reply Last reply
      0
      • AmrCoderA Offline
        AmrCoderA Offline
        AmrCoder
        wrote on last edited by
        #3

        @mrjj it still showed in the middle of the table view, not in the cell

        mrjjM 1 Reply Last reply
        0
        • AmrCoderA AmrCoder

          @mrjj it still showed in the middle of the table view, not in the cell

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @AmrCoder
          Ok, it seems to have

           WaitingSpinnerWidget(QWidget *parent = 0,
                                   bool centerOnParent = true,
                                   bool disableParentWhenSpinning = true);
          

          try create it with FALSE for centerOnParent
          as in
          pinnerProgressBar bar = new SpinnerProgressBar(0, FALSE);

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved