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] QTableWidgetItem no data only check flag

[SOLVED] QTableWidgetItem no data only check flag

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 6.2k 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.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    I've got some QTableWidget, and initializing items like this:
    @QTableWidgetItem * item = table->item(i,j);

    if(item == NULL)
    {
    item = new QTableWidgetItem();
    item->setFlags(Qt::NoItemFlags);
    m_ui->tableWidget->setItem(i,j,item);
    }

    if(m_ec.matrix[headerId_i][headerId_j]) // value
    item->setData(Qt::CheckStateRole, Qt::Checked);
    else
    item->setData(Qt::CheckStateRole, Qt::Unchecked);

    if(m_rn.matrix[headerId_i][headerId_j]))// readonly
    item->setFlags(Qt::NoItemFlags);
    else
    item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsUserCheckable);@
    I mean I need checkable items in table with maybe some UserRole data and toolTips but w/o Display data. I get this but I still have some space in cells of my table. The question is how to remove or maybe hide these empties ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Anticross
      wrote on last edited by
      #2

      Or maybe anyone know how to set chekbox in center of cell ?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        You can only put the checkbox in the center of a cell, if you create your own delegate. That is not worth it, I think.

        Couldn't you just make the column with your checkboxes narrow enough so it basically only shows your check box?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Anticross
          wrote on last edited by
          #4

          Thanks. I think it's really don't worth it to make a delegate. I asked because I don't know simple method but maybe someone knows. I resize my column close enough but some header text is bigger then 3 symbols long, so there is no way to do SIMPLE nice look, without using delegate.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            You could considder, if you have space to fill, to just put a textual representation of the value next to the check box. Depending on the meaning, that could be yes/no, true/false, on/off, or something short and simple like that.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              Anticross
              wrote on last edited by
              #6

              I found solution I made my horizontal headers only digits in data role, and all text in tool tip role, but vertical header leave with text(because it's actually duplicates horizontal header) . So now it has a nice look. Andre, thanks for the help.

              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