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. [SOLVED]Blink text in table
Forum Update on Monday, May 27th 2025

[SOLVED]Blink text in table

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 6.1k Views
  • 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.
  • T Offline
    T Offline
    toho71
    wrote on last edited by
    #1

    I got at tableview with items from a model.

    Some of the rows should "Blink"
    Just like in html and the Blink tag

    I Use a QBrush (myBlink) to set the color of the text.

    In a timerevent I simple change the Qbrush (myBlink) color but nothing happens.

    I know that the timerevent runs.

    I have tried to repaint the tabelview but nothing happens.

    is it possible to do like this:
    Maybe i should use the paintevent or something;
    pls help

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      if you have a custom model (so using the QTableView, not QTableModel), you could change the data in the model and send dataCHanged signal. If you use the widgets style (QTableWidget) you can change the background color for the item in the widget. it should update immediatly.

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toho71
        wrote on last edited by
        #3

        Thank you but i don't think that this is the solution.(Maybe!)
        I suppose that I have to loop thru the whole model if I use your replay.
        and set the datamodels data.

        That's a final solution that I hope to avoid

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dangelog
          wrote on last edited by
          #4

          You can't avoid that solution. You MUST emit dataChanged with a proper range in order to make the view fetch the new values for the foreground text color (then provide the new color in data()).

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply
          0
          • T Offline
            T Offline
            toho71
            wrote on last edited by
            #5

            Ok I try

            Any cute loop to use
            Maybe

            @foreach(datamodel.rowcount,datamodel.columnCount){}
            @
            or

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              Do you have a standard model or a custom one?

              If you have a custom model, it's fairly trivial. Yust store the data inside it and call

              @
              emit dataChanged(createIndex(firstRow, blinkColumn), createIndex(lastRow, blinkColumn));
              @

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • T Offline
                T Offline
                toho71
                wrote on last edited by
                #7

                I solved it in my own way.
                @void Logs::BlinkTextRows()

                {

                int row_count = model->rowCount();
                int col_count = model->columnCount();
                
                QModelIndex index;
                
                
                for( int i = 0; i < row_count; i++ )
                {
                       if (model->item(i,3)->data(Qt::DisplayRole).toString().compare("yes",Qt::CaseInsensitive) == 0)
                       {
                                if (model->item(i,4)->data(Qt::CheckStateRole) == Qt::Unchecked)
                                {
                                  for (int j = 0;j < col_count;j++)
                                  {
                                      index = model->indexFromItem(model->item(i,j));
                                      if (hidden)
                                          model->setData(index, myblink, Qt::ForegroundRole);
                                      else
                                          model->setData(index, myblink, Qt::ForegroundRole);
                                  }//for
                               } //if model..
                          } //if compare
                }//For i
                
                if (hidden)
                    hidden = false;
                else
                    hidden = true;
                

                }@

                It wasn't so hard in the end

                1 Reply Last reply
                0

                • Login

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