Results 1 to 2 of 2

Thread: QList problem

  1. #1
    Join Date
    Sep 2009
    Location
    Belgrade, Serbia
    Posts
    40
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QList problem

    Problem is probably stupid but so far I failed to find what I am doing wrong.

    I have in my project these two classes:

    Qt Code:
    1. class RegularJobLayout : public QHBoxLayout
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. RegularJobLayout(const QString &title, const int index, QWidget *parent = 0);
    7.  
    8. protected slots:
    9. void setPrintSlot();
    10. void setPackSlot();
    11. void setProcessSlot();
    12.  
    13. protected:
    14. void setJobLayout(const QString &title);
    15. void setJobGroupBox(const QString &title);
    16.  
    17. void initializePrintModel();
    18. QStandardItem* initializeTwinItem(QStandardItem *parent);
    19. QStandardItem* initialize3110Item(QStandardItem *parent);
    20. QStandardItem* initializeCPSItem(QStandardItem *parent);
    21.  
    22. void initializePackModel();
    23. QStandardItem* initializePackItem(QStandardItem *parent);
    24.  
    25. QStandardItem* initializePrintPackChildItem(QStandardItem *parent);
    26.  
    27. void initializeProcessingModel();
    28.  
    29. int m_index;
    30.  
    31. QLabel *m_jobNameLabel;
    32. QLineEdit *m_jobNameLineEdit;
    33.  
    34. QLabel *m_userCountLabel;
    35. QSpinBox *m_userCountSpinBox;
    36.  
    37. QLabel *m_duplexLabel;
    38. QComboBox *m_duplexComboBox;
    39.  
    40. QLabel *m_resolutionLabel;
    41. QComboBox *m_resolutionComboBox;
    42.  
    43. QLabel *m_deliveryLabel;
    44. QComboBox *m_deliveryComboBox;
    45.  
    46. QLabel *m_shipmentLabel;
    47. QComboBox *m_shipmentComboBox;
    48.  
    49. QTreeView *m_printTreeView;
    50. QStandardItemModel *m_printItemModel;
    51. QPushButton *m_printButton;
    52.  
    53. QTreeView *m_packTreeView;
    54. QStandardItemModel *m_packItemModel;
    55. QPushButton *m_packButton;
    56.  
    57. QTreeView *m_processingTreeView;
    58. QStandardItemModel *m_processingItemModel;
    59. QPushButton *m_processingButton;
    60.  
    61. QGroupBox *m_jobGroupBox;
    62. QGridLayout *m_jobGroupBoxLayout;
    63.  
    64. QSpacerItem *m_leftJobSpacerItem;
    65. QSpacerItem *m_rightJobSpacerItem;
    66. };
    67.  
    68. class RegularCentralWidget : public QWidget
    69. {
    70. Q_OBJECT
    71.  
    72. public:
    73. RegularCentralWidget(QWidget *parent = 0);
    74.  
    75. protected:
    76. RegularHeaderLayout *m_headerLayout;
    77.  
    78. QList<RegularJobLayout> *m_jobList;
    79.  
    80. QVBoxLayout *m_layout;
    81. };
    To copy to clipboard, switch view to plain text mode 

    I had five separate RegularJobLayout pointers in my RegularCentralWidget class but decided that this is a more professional approach. Easier to update my code at later time. In the constructor I have the following code:

    Qt Code:
    1. RegularCentralWidget::RegularCentralWidget(QWidget *parent) : QWidget(parent)
    2. {
    3. m_headerLayout = new RegularHeaderLayout();
    4.  
    5. m_layout = new QVBoxLayout(this);
    6.  
    7. m_layout->addLayout(m_headerLayout);
    8.  
    9. int index, maxJobs = 5;
    10. QString title;
    11.  
    12. m_jobList = new QList<RegularJobLayout>();
    13.  
    14. for(index = 0; index < maxJobs; ++index)
    15. {
    16. title.setNum(index+1);
    17. title.prepend("Posao ");
    18.  
    19. m_jobList->append(new RegularJobLayout(title, index)); //This line fails
    20.  
    21. m_layout->addLayout(m_jobList[index]); //This line fails
    22. }
    23. }
    To copy to clipboard, switch view to plain text mode 

    Constructor can probably be better but I am still trying to make it work. I get the following errors:

    /home/ivan/Development/Qt/RadniNalog/WorkOrder0.2.3/wouil.cpp:155: error: no matching function for call to ‘QList<telekom::workorder::RegularJobLayout> ::append(telekom::workorder::RegularJobLayout*)â⠂¬â„¢
    /usr/include/qt4/QtCore/qlist.h:422: note: candidates are: void QList<T>::append(const T&) [with T = telekom::workorder::RegularJobLayout]
    /usr/include/qt4/QtCore/qlist.h:623: note: void QList<T>::append(const QList<T>&) [with T = telekom::workorder::RegularJobLayout]
    /home/ivan/Development/Qt/RadniNalog/WorkOrder0.2.3/wouil.cpp:157: error: no matching function for call to ‘QVBoxLayout::addLayout(QList<telekom::worko rder::RegularJobLayout>&)’
    /usr/include/qt4/QtGui/qboxlayout.h:86: note: candidates are: void QBoxLayout::addLayout(QLayout*, int)

    If somebody would help me to figure out where am I making a mistake I would really appreciate it.

    Thanks in advance.

  2. #2
    Join Date
    Sep 2009
    Location
    Belgrade, Serbia
    Posts
    40
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList problem

    I went to sleep and when I woke up I figured out that I forgot the *. It should be QList<RegularJobLayout*>. Stupid mistake.

Similar Threads

  1. Problem with QList
    By Gargolissimus in forum Newbie
    Replies: 8
    Last Post: 6th July 2009, 16:24
  2. QList problem
    By lvi in forum Qt Programming
    Replies: 3
    Last Post: 25th August 2008, 18:22
  3. problem with QList
    By dreamer in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2008, 13:08
  4. problem in QList< QWidget *>
    By wei243 in forum Qt Programming
    Replies: 2
    Last Post: 22nd September 2007, 04:51
  5. QList problem
    By acix in forum General Programming
    Replies: 6
    Last Post: 29th April 2006, 13:08

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
  •  
Qt is a trademark of The Qt Company.