Results 1 to 4 of 4

Thread: emitting signals in const function

  1. #1
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default emitting signals in const function

    Hey there,
    i have written a ComboBoxDelegate an want to emit a signal in a const function. VusualC++ returns the Error
    "error C2662: 'ComboBoxDelegate::currentIndexChanged': this-pointer cann't be changed from 'const ComboBoxDelegate' in 'ComboBoxDelegate &'"

    Anny ideas?

    void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
    {
    if(index.isValid()&&index.column()==ViewSpalte)
    {
    QComboBox* combo = qobject_cast<QComboBox*>(editor);
    int idx=combo->currentIndex();
    int nidx=index.model()->data(index,Qt:isplayRole).toInt();
    combo->setCurrentIndex(nidx);
    if(idx!=nidx)
    emit currentIndexChanged(nidx); // the Error occurs here
    }
    else
    QItemDelegate::setEditorData(editor, index);
    }

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: emitting signals in const function

    have you tried declaring the signal as const, too?

  3. #3
    Join Date
    Feb 2006
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emitting signals in const function

    Thank's, thats it! Its too simple. sorry

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: emitting signals in const function

    Emitting a "currentIndexChanged" signal from setEditorData is probably a design flaw regardless of constness.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.