Results 1 to 6 of 6

Thread: [SOLVED] QSignalMapper and QStandardItemModel

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2014
    Posts
    94
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default [SOLVED] QSignalMapper and QStandardItemModel

    Hello everyone!

    I need to link a button click signal to add a row in my QStandardItemModel and I am trying to do this way, but It's not going OK.

    Qt Code:
    1. void MainWindow::on_pushButtonNovoInvestimento_clicked()
    2. {
    3. QPushButton *pushButtonAdicionarLancamentoInvestimento = new QPushButton;
    4. pushButtonAdicionarLancamentoInvestimento->setText("Adicionar lançamento");
    5.  
    6. QTableView *tableViewLancamentosInvestimento = new QTableView;
    7. QStandardItemModel *modeloLancamentosInvestimento = new QStandardItemModel(0, 2, this);
    8. modeloLancamentosInvestimento->setHeaderData(0, Qt::Horizontal, "Valor");
    9. modeloLancamentosInvestimento->setHeaderData(1,Qt::Horizontal, "Ações");
    10. tableViewLancamentosInvestimento->setModel(modeloLancamentosInvestimento);
    11.  
    12. connect(pushButtonAdicionarLancamentoInvestimento, SIGNAL(clicked()), mapper, SLOT(map()));
    13. mapper->setMapping(pushButtonAdicionarLancamentoInvestimento, modeloLancamentosInvestimento);
    14. connect(mapper, SIGNAL(mapped(QObject*)), this, SLOT(on_pushButtonAdicionarLancamentoInvestimento_clicked(QObject*)));
    15. }
    16.  
    17. void MainWindow::on_pushButtonAdicionarLancamentoInvestimento_clicked(QObject *modeloLancamentosInvestimento)
    18. {
    19. QStandardItemModel *modelo = modeloLancamentosInvestimento;
    20. }
    To copy to clipboard, switch view to plain text mode 

    How can I do that?

    Thanks a lot
    Last edited by guidupas; 17th April 2014 at 23:12.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSignalMapper and QStandardItemModel

    Wouldn't it be easier to just have the model as a member of MainWindow?

    Cheers,
    _

Similar Threads

  1. QSignalMapper
    By Cremers in forum Newbie
    Replies: 5
    Last Post: 25th July 2013, 20:54
  2. QSignalMapper
    By Ali Reza in forum Newbie
    Replies: 35
    Last Post: 30th November 2012, 09:12
  3. QSignalMapper
    By axisdj in forum Newbie
    Replies: 6
    Last Post: 16th September 2010, 01:52
  4. help with QSignalMapper and actions
    By andreime in forum Newbie
    Replies: 1
    Last Post: 9th August 2009, 18:24
  5. ? about QSignalMapper
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2008, 21:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.