Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: qt4 QStringList with model/view

  1. #21
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt4 QStringList with model/view

    If I do as you propose (ie declare the selector in the mainform), then the code that's supposed to retrieve the rows selected in the selector class fails.
    Qt Code:
    1. // Destinataires Destinataires_dlg( this ); <- in main form in your new syntax
    2. model->removeRows(0, model->rowCount(QModelIndex()), QModelIndex());
    3.  
    4. // add number of char available
    5. int NbCharRestants = NbCharSMSMax - qMessage->toPlainText().length();
    6. s.setNum(NbCharRestants,10);
    7. s = TxtCharSMSMax + " " + s;
    8. appendRow( s );
    9. // add sms credit
    10. qMajCredit();
    11. // get the selected destinations
    12. QStringList ret = Destinataires_dlg.getDestList(); <- compile error
    13. if ( ret.size() )
    14. {
    15. appendRow ( TxtDestinataires );
    16. for( int i = 0; i < ret.size(); i++) appendRow ( ret[i] );
    17. }
    18. else
    19. {
    20. s = TxtDestinataires + " * " + TxtIndefini;
    21. appendRow( s );
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    147 C:\Qt\test\sms\menu.cpp `getDestList' has not been declared

  2. #22
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt4 QStringList with model/view

    Quote Originally Posted by incapacitant
    Qt Code:
    1. // Destinataires Destinataires_dlg( this ); <- in main form in your new syntax
    2. ...
    3. QStringList ret = Destinataires_dlg.getDestList(); <- compile error
    To copy to clipboard, switch view to plain text mode 
    The compiler doesn't know any "Destinataires_dlg" variable, because it's commented out.
    Instead of this, you have to refer to the dialog which you have created somewhere else and stored as a member variable.

  3. #23
    Join Date
    Jan 2006
    Location
    Grenoble, France
    Posts
    165
    Thanks
    106
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: qt4 QStringList with model/view

    I have declared the selector window in the main form code and added as class variable:
    Qt Code:
    1. Destinataires_dlg = new Destinataires(this);
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. public:
    2. ApplicationWindow();
    3. ~ApplicationWindow();
    4. Destinataires *Destinataires_dlg;
    To copy to clipboard, switch view to plain text mode 

    But I still get the same compile error !
    So I cannot get the selection from the selector screen in the main code.

  4. #24
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: qt4 QStringList with model/view

    So it's a pointer, you need to use "->"-operator.. a basic c++ principle..
    Qt Code:
    1. QStringList ret = Destinataires_dlg->getDestList();
    To copy to clipboard, switch view to plain text mode 

  5. The following user says thank you to jpn for this useful post:

    incapacitant (17th March 2006)

Similar Threads

  1. QStringList
    By jaca in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2008, 10:12
  2. QStringList scope problem
    By ht1 in forum Qt Programming
    Replies: 5
    Last Post: 30th November 2007, 19:44
  3. QStringList in QObject::connect
    By DPinLV in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2006, 17:01
  4. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 20:48
  5. need help to classify some QStringList
    By patcito in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 21:24

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.