def use_qgrid(df, **kwargs):
    """Create a ``QgridWidget`` object from the
    `qgrid library <https://qgrid.readthedocs.io/en/latest/>`_ in
    **Jupyter Notebooks**.

    This allows the creation of a interactive table in a cell with a whole
    lot of functionalities (see `qgrid documentation <https://qgrid.readthedocs.io/en/latest/>`_)

    A part from the :class:`~pandas.DataFrame`, one can provide any named parameter that can
    be applied to `qgrid.show_grid <https://qgrid.readthedocs.io/en/latest/#qgrid.show_grid>`_.
    The only difference is that if there are more than 4 columns, the key ``forceFitColumns``
    from the attribute ``grid_options`` is forced into :data:`False`.

    The actual :class:`~pandas.DataFrame` can be retrieved back with::

        qwdf = rstoolbox.utils.use_qgrid(df)
        qdf = qwdf.get_changed_df()
        # OR
        qdf = qwdf.get_selected_df()

    See more in the documentation for
    `get_changed_df <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.get_changed_df>`_
    or `get_selected_df <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget.get_selected_df>`_.

    Best used together with :func:`.format_Ipython`.

    :param df: Data container.
    :type df: :class:`~pandas.DataFrame`

    :return: `QgridWidget <https://qgrid.readthedocs.io/en/latest/#qgrid.QgridWidget>`_

    :raises:
        :ImportError: If `qgrid library <https://qgrid.readthedocs.io/en/latest/>`_
            is not present.
    """
    try:
        import qgrid
    except ImportError:
        raise ImportError(
            'qgrid (not mandatory on rstoolbox install) is necessary to execute this function.'
            )
    go = kwargs.pop('grid_options', {})
    if df.shape[1] > 4:
        go['forceFitColumns'] = False
    return qgrid.show_grid(df, grid_options=go, **kwargs)
