Forum
Sign Up
× DataGrid for Qt.C++

Modifying QtitanDataGrid using QSS

12 years 9 months ago #1 by Stefan
Modifying QtitanDataGrid using QSS was created by Stefan
My application uses QSS for some styling. I am slowly changing all QTableViews over to QtitanDataGrids. I would like to be able to keep the styling in my app consistent by applying the same styles to all QtitanDataGrids.

It seems that QTableView and QTreeView styles do not affect QtitanDataGrid, so either QtitanDataGrid doesn't use QTableView and QTreeView behind the scenes or the style information is not getting the the underlying QTableView and QTreeView.

Any help with this would be appreciated.

:wq

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

  • Stefan
  • Stefan's Avatar Topic Author
12 years 9 months ago #2 by Developer Machines
In the QtitanDataGrid not all elements are rendered with QStyle. It is especially true for elements that are not in the Qt's QTableView. If possible, attach a few screenshots here that show the difference in the rendering of elements in two tables.

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

More
8 years 10 months ago - 8 years 10 months ago #3 by amabilisa
Please, tell me about qss rules for Grid of QTitanDataGrig (something like manual or examples). I want to use propesties like QTableView and QTableWidget use (the most necessary are: border, color and background (for table and for header apart), selection-color, selection-background-color, alternate-background-color or item:alternate etc.), but I don't know what object names and properties I can use in my stylesheets. I can't find similar manual.
Last edit: 8 years 10 months ago by amabilisa.
The following user(s) said Thank You: Developer Machines

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

More
8 years 9 months ago #4 by Developer Machines
Qt-CSS is not an exhaustive way to change grid settings. I'd suggest to use Grid API for such purposes. But some of the elements can be changed, please use the following snippet:
    m_grid = new Qtitan::Grid();
    m_grid->setStyleSheet(" Qtitan--Grid { alternate-background-color: blue; background: yellow; }");
    m_grid->setViewType(Qtitan::Grid::TableView);

P.S. Please note, CSS should be embedded before grid-view was created.
The following user(s) said Thank You: amabilisa

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

More
8 years 9 months ago - 8 years 9 months ago #5 by Developer Machines
P.S.S. For instance, to change grid lines via API please use:
    Qtitan::GridTableView* view = m_grid->view<Qtitan::GridTableView>();
    QPen pen = view->options().gridLinePen();
    pen.setStyle(Qt::DotLine);
    view->options().setGridLinePen(pen);
    view->options().setGridLineColor(Qt::red);
    view->options().setGridLineWidth(2);
    view->options().setGridLines(Qtitan::LinesVertical);

All of these examples can be found in our demo.
Last edit: 8 years 9 months ago by Developer Machines.
The following user(s) said Thank You: amabilisa

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

More
8 years 9 months ago - 8 years 9 months ago #6 by amabilisa
I'm interested in way to change border style by qss (Qtitan--Grid { border: none; } doesn't work). Can you answer what names of Qtitan classes I can use to change style of grid border, grid header (background and text colors, font family and size), customize scroll and sort/filter buttons in header (place and icon)? And how adjust colunm width to contents? Maybe you can take me the link to similar manual? I must use qss by design requirements of my project.
Last edit: 8 years 9 months ago by amabilisa.

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

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.151 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 )