0

in my Qt project, I have a list of Clients. I have to show their name and workplace. Proposed ui looks something like this:

Client table

Facts:

  1. Number of client is variable, so the number of dotted rectangular box in the image is not fixed
  2. stylesheet of Name and Some info is different
  3. When clicked on the box (a cell in the table), we have to show something like user/client profile for that client.

What we tried:

We tried using tablewidget, but can't handle the function of showing profile based on click on table cell.

We need suggestion how we can implement that.

Shakib Ahmed
  • 781
  • 2
  • 10
  • 24
  • You can simply handle the `QTableWidget::itemClicked()` signal and show the profile from the slot it connected to. – vahancho Jul 05 '14 at 14:18

1 Answers1

1

I don't think using tablewidget is the best idea here (But it could be, depending on your needs and if you pay attention to future evolution).

I think a good solution could be to create a custom widget MyCell which would be a cell (Pretty sure you guess it thanks to the name ;) !)

In this MyCell class you can add your information (probably QLineEdit ? No really matter in our example).

Then you have to implement QWidget::mousePressEvent(QMouseEvent *event) function, and do what you want in it (Open a new Dialog in your case).

You can have a class MyTable with N MyCell put in a QGridLayout.

Martin
  • 877
  • 8
  • 20