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. Highlight table column

Highlight table column

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.2k Views 1 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.
  • B Offline
    B Offline
    Bruschetta
    wrote on last edited by A Former User
    #1

    Hello , i have a QStandardItemModel table and i'd like to highlight one of the column after the occurrence of an event.

    To be more clear i have this situation at start
    alt text

    in this other picture is shown what i'm trying to reach. this is what is happening when i'm clicking the header of the table definited by HorizontalHeaderLabel "4". So basically I'm trying to figure out how to simulate the click on the header defined by headerlabel "4"
    alt text

    And this is the way i get the column values

    void measure::on_tableViewTop_clicked(const QModelIndex &index)
    {
         ui->tableViewTop->setCurrentIndex (index);
         int r = index.row();
         int c = index.column ();
         qDebug() << "Row: " << r;
         qDebug() << "Column: " << c;
         qDebug() << "X: " <<   ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(0,c)).toString();
         qDebug() << "Y: " <<   ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(1,c)).toString(); 
         qDebug() << "Z: " <<   ui->tableViewTop->model()->data(ui->tableViewTop->model()->index(2,c)).toString();
    }
    

    Hope you can help ;) And forive me for my not so clear english :P

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bruschetta
      wrote on last edited by
      #2

      Noone knows how to do it? :(

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Hi! Please refrain from thread bumping.

        Selecting items is done in the view, not in the model. void QTableView::selectColumn(int column) [slot], see: QTableView Class.

        1 Reply Last reply
        1
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          What's your view selectionMode and selectionBehaviour? do you reimplement a selectEvent?

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          B 1 Reply Last reply
          2
          • VRoninV VRonin

            What's your view selectionMode and selectionBehaviour? do you reimplement a selectEvent?

            B Offline
            B Offline
            Bruschetta
            wrote on last edited by
            #5

            @Wieland said in Highlight table column:

            Hi! Please refrain from thread bumping.

            Selecting items is done in the view, not in the model. void QTableView::selectColumn(int column) [slot], see: QTableView Class.

            Sorry didn't want to spam or do thread bumbing. It's the first time i'm having this behaviour after many posts

            @VRonin said in Highlight table column:

            What's your view selectionMode and selectionBehaviour? do you reimplement a selectEvent?

            The selection mode is "ExtendedSelection" while the selectionBehaviour is "SelectItems"
            Changing it to selectColumns seems to do what i wanted to do...

            Thanks for pointing me to the right direction ;)

            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