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. QTableview properties
Forum Updated to NodeBB v4.3 + New Features

QTableview properties

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • saeedhardanS Offline
    saeedhardanS Offline
    saeedhardan
    wrote on last edited by
    #1

    hi , i have defined qtableview as this example i found on the internet :
    @
    model = new QStandardItemModel(2,3,this); //2 Rows and 3 Columns
    model->setHorizontalHeaderItem(0, new QStandardItem(QString("ID")));
    model->setHorizontalHeaderItem(1, new QStandardItem(QString("Name")));
    model->setHorizontalHeaderItem(2, new QStandardItem(QString("Description")));
    ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    ui->tableView->setModel(model);
    @

    i'm not finding no help using google with the following issues ,can somebody help pls :
    1 - how can i define a size for every columns using percentages , meaning i.e first columns 10% of the width second 50% ,third 40% .

    2 - how can i disable when double clicking on a row the edit . i mean when i double click on a row it is possible to change the value of the clicked column in a specified row .

    3 - if possible that when on doubleclick to highlight the whole row not only the column .

    4 - make the columns resizable , meaning can be resized with the mouse dragging them .
    thank you

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2
      1. Did you look at the setDefaultSectionSize(...). With this you need to do your math to set appropriate size.

      2. Did you look at setSectionResizeMode(...) ?

      3. 2 and 3 are confused slightly. However you can do this with handling MouseHandling on your view

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • saeedhardanS Offline
        saeedhardanS Offline
        saeedhardan
        wrote on last edited by
        #3

        !http://i57.tinypic.com/fu1gkp.png(example)!

        in this picture 1(in red) shows what i talked about in 2 above .
        2(in red) what i mean by highlighting the whole row .

        [quote author="Dheerendra" date="1410196137"]1. Did you look at the setDefaultSectionSize(...). With this you need to do your math to set appropriate size.
        [/quote]
        it didn't work , and it only takes one argument , how can i specify for each column a size .

        1 Reply Last reply
        0
        • saeedhardanS Offline
          saeedhardanS Offline
          saeedhardan
          wrote on last edited by
          #4

          Hi all , im still looking for an answer , if it helps it doesn't have to be a tableview , i just need to list rows and flixible columns .

          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