Forum
Sign Up
× DataGrid for Qt.C++

reusing qtitangrid widget

13 years 11 months ago #1 by corrado valeri
reusing qtitangrid widget was created by corrado valeri
I have a qdialog persisted in a ui file, that contains a qtitangrid widget.
the firs time I assign a sqlquerymodel to the qtitangrid widget view, it works fine.
The second time I set the sqlquerymodel to the view, the qtitangrid widget is showed without the grid.

Which is the correct workflow to reuse qtitangrid widget ?

this is the function i call twice from outside the widget to populate the model:
bool dlg_griglia_piano_circolazione::load_piano_circolazione(QString &errors)
{
    QLOG_ENTERFUNC;   
    bool esito = false;
    QSqlQueryModel * piano_da_analizzare = new QSqlQueryModel(this);
    piano_da_analizzare->setQuery(this->get_sql() , this->get_database());

    if (((QSqlQueryModel*)piano_da_analizzare)->lastError().isValid())
    {
        QString errore = ((QSqlQueryModel*)piano_da_analizzare)->lastError().text();
        QLOG_ERROR() << errore;
        errors.append(errore);
    }
    else
    {
        QLOG_DEBUG()<< "qry ok, proseguo con fetchmore";
        int counter = 0;
        while (piano_da_analizzare->canFetchMore())
        {
            piano_da_analizzare->fetchMore();
            counter++;
        }
        if (counter > 0)
        {
            QLOG_TRACE()<< "fetchMore chiamato"<<counter<<"volte";
        }

        QLOG_DEBUG() << "totale righe caricate:"<< piano_da_analizzare->rowCount();
        this->ui->grid->setViewType(Qtitan::Grid::TableView);
        Qtitan::GridTableView * view = this->ui->grid->view<Qtitan::GridTableView>();
        view->options().setRowAutoHeight(true);
        view->options().setColumnAutoWidth(true);
        view->setModel(piano_da_analizzare);
        esito = true;
    }
    if ((esito) && (piano_da_analizzare->rowCount() > 0))
        load_grid_layout_from_file();
    return esito;

    QLOG_EXITFUNC;
}

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

  • corrado valeri
  • corrado valeri's Avatar Topic Author
13 years 10 months ago #2 by corrado valeri
Replied by corrado valeri on topic reusing qtitangrid widget
Hello,
I made a progress: the grid is not shown until I force a resize of the widget, just few pixel, and the grid appears. Maybe is a redraw problem.

Right now I'm working around another issue: the hidden columns that are persisted to xml, after loadLayoutFromFile method are shown instead to be hidden. :blink:

Do you confirm this issue?

bye

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

  • corrado valeri
  • corrado valeri's Avatar Topic Author
13 years 10 months ago #3 by Developer Machines

corrado wrote: Hello,
I made a progress: the grid is not shown until I force a resize of the widget, just few pixel, and the grid appears. Maybe is a redraw problem.
bye


This is a bug in the QtitanDataGrid. It has already been fixed and will be available in the update to be released this week. I apologize for the inconvenience.

corrado wrote: Right now I'm working around another issue: the hidden columns that are persisted to xml, after loadLayoutFromFile method are shown instead to be hidden. :blink:

Do you confirm this issue?


Thanks for the info. I am investigating this problem and if it confirmed it will be fixed so as this week.

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

More
13 years 10 months ago - 13 years 10 months ago #4 by Developer Machines
Other way, you can not try to recreate the SQL model in the second stage but get it from the reference to tableView, which received in the first stage.
Like this:
....
this->ui->grid->setViewType(Qtitan::Grid::TableView);
Qtitan::GridTableView * view = this->ui->grid->view<Qtitan::GridTableView>;
m_gridView = view;
....

QSqlQueryModel* piano_da_analizzare = qobject_cast<QSqlQueryModel *>(m_gridView->model());
if (piano_da_analizzare)
    piano_da_analizzare->setQuery(this->get_sql() , this->get_database());
Last edit: 13 years 10 months ago by Developer Machines.
The following user(s) said Thank You: corrado valeri

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

More
13 years 10 months ago - 13 years 10 months ago #5 by corrado valeri
Replied by corrado valeri on topic reusing qtitangrid widget

bigz wrote: This is a bug in the QtitanDataGrid. It has already been fixed and will be available in the update to be released this week. I apologize for the inconvenience.


Is there a workaround to solve this issue temporary?
This week I must release the software and I'm looking for a workaround.
Another info: when the grid is displayed "hided", if you click over it an acces violation is thrown.
Last edit: 13 years 10 months ago by corrado valeri.

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

  • corrado valeri
  • corrado valeri's Avatar Topic Author
13 years 10 months ago - 13 years 10 months ago #6 by Developer Machines
For the present i can recommend to try just the way which i described above.
Please provide more information or sample code how to get AV on hidden grid.

Can you tell, the line of code where AV is occur?
Last edit: 13 years 10 months ago by Developer Machines.

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.187 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 )