Forum
Sign Up
× DataGrid for Qt.C++

How can i make a cell looks like a pushbutton?

11 years 11 months ago #1 by
Hi,
i need a column with cells looks like a pushbutton (see screenshot). When the user pressed these button a dialog will be open. How can i make an editor for that?
Thanks
Attachments:

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
11 years 11 months ago - 11 years 11 months ago #2 by Developer Machines
This can be done by implementing a special editor of the cell.

Another variant. Grid has a mechanism which allows you to add buttons to any cell with any editor.


GridTableColumn::addButton(CellButtonKind kind = SelectButton, CellButtonPosition position = RightPosition, CellButtonActivatePolicy policy = FixedPolicy, const QIcon& icon = QIcon());

Below code to do that:
    Qtitan::GridTableColumn* column = (Qtitan::GridTableColumn *)view->getColumnByModelColumnName("Date");
    column->addButton(Qtitan::ClearButton, Qtitan::RightPosition, Qtitan::MouseOverPolicy);
    connect(column, SIGNAL(buttonClicked(CellButtonClickEventArgs*)), this, SLOT(cellButtonClicked(CellButtonClickEventArgs*)));
.....
void Window::cellButtonClicked(CellButtonClickEventArgs* args)
{
    QMessageBox::information(this, tr("Cell button clicked (new)"), 
        tr("Clicked: Button - %1, Column Title - %2, RowIndex - %3").arg(args->buttonIndex()).arg(args->column()->caption()).arg(args->row()->rowIndex()));
}

There's only one problem. In the current implementation a text can not be assigned to button.
If you find this solution acceptable, we will add the possibility to assign the text to the button in the next release.
Last edit: 11 years 11 months ago by Developer Machines.

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #3 by
The solution is acceptable. But some more question:
If i what a special icon in the button, which CellButtonKind must i choose?
How can i enable/disable the button?
Thanks

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
11 years 11 months ago #4 by Developer Machines
You need to use CellButtonKind::IconButton.

Unfortunately enabling/disabling cell's button is not provided in this version of the grid.
You need to disable all the button in the column or in the certain row?

Please Log in or Create an account to join the conversation.

More
11 years 11 months ago #5 by
I need to to disable a button in a certain row.

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
11 years 11 months ago #6 by
How can i set a tooltip-text for the button?

Please Log in or Create an account to join the conversation.

  • 's Avatar Topic Author
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.174 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )