Results 1 to 20 of 44

Thread: QItemDelegate Align

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    I got one more question for the tool botton

    I create a action, and add to toolbotton.

    Qt Code:
    1. QAction *enDusukAlis = new QAction(QString::fromUtf8("En DüşÃ¼k Alış Fiyatı"), w->toolButton());
    2. connect(enDusukAlis, SIGNAL(activated()), w->toolButton(), SLOT(slotenDusukAlis()));
    3. w->toolButton()->addAction(enDusukAlis);
    To copy to clipboard, switch view to plain text mode 

    this slotenDusukAlis has to find something and put a number in a spin. But I was not able to work signal and slot can anybody help?

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: QItemDelegate Align

    looks strange
    Qt Code:
    1. connect(enDusukAlis, SIGNAL(activated()), w->toolButton(), SLOT(slotenDusukAlis()));
    To copy to clipboard, switch view to plain text mode 
    QToolButton has not such slot slotenDusukAlis.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    Dear All

    What I need to do is,

    I have QAction's on the QToolMenu,

    Like
    Best Price '10'
    Low Price '8'

    What I need to do is, after user select Best Price '10' I need to put 10 to the spin...

    Am I able to explain?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QItemDelegate Align

    a) use QRegExp to extract the number of the displayed text
    or better
    b) use QAction::setData() to store your number while generating the QActions

    use the QToolButton::triggered ( QAction * action ) signal.

  5. #5
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    What I use is,

    Qt Code:
    1. QAction *enDusukAlis = new QAction(QString::fromUtf8("En DüşÃ¼k Alış Fiyatı"), w->toolButton());
    2. connect(enDusukAlis, SIGNAL(activated()), this, SLOT(slotenDusukAlis()));
    3. w->toolButton()->addAction(enDusukAlis);
    To copy to clipboard, switch view to plain text mode 

    But the signal doesnt work

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QItemDelegate Align

    A QAction has only the signals:
    void changed ()
    void hovered ()
    void toggled ( bool checked )
    void triggered ( bool checked = false )
    void destroyed ( QObject * obj = 0 )

    No activated!

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: QItemDelegate Align

    yup, Qt Assistant -- rocks!
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #8
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    Quote Originally Posted by spirit View Post
    yup, Qt Assistant -- rocks!
    yes, it really rocks!

    For the setData how can I use it then?

  9. #9
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    Qt Code:
    1. .....
    2. QAction *enDusukSatis = new QAction(QString::fromUtf8("En DüşÃ¼k Satış Fiyatı"), w->toolButton());
    3. connect(enDusukSatis, SIGNAL(triggered()), this, SLOT(test()));
    4. w->toolButton()->addAction(enDusukSatis);
    5. .....
    6. void ProformaDelegate::test()
    7. {
    8. QMessageBox::warning(0, QString::fromUtf8("HATA"),
    9. QString::fromUtf8("İşlemde bir hata oluştu \nLütfen tekrar deneyiniz \nveya \nSistem uzmanına başvurunuz"));
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

    But the signal doent work...

  10. #10
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: QItemDelegate Align

    everything should work, press and hold a tool button, a popup menu should appear with your action. if you want slot is being called immediately then
    Qt Code:
    1. connect(w->toolButton(), SIGNAL(clicked()), this, SLOT(test()));
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  11. #11
    Join Date
    Jan 2007
    Posts
    201
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    22

    Default Re: QItemDelegate Align

    Dear Spirit

    Qt Code:
    1. connect(w->toolButton(), SIGNAL(clicked()), this, SLOT(test()));
    To copy to clipboard, switch view to plain text mode 

    also doesnt work

  12. #12
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: QItemDelegate Align

    Then show us your (whole) code. Maybe Q_OBJECT forgotten? Do you get a warning?

  13. #13
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 370 Times in 336 Posts

    Default Re: QItemDelegate Align

    what does this operation show in console?
    Qt Code:
    1. qDebug() << connect(w->toolButton(), SIGNAL(clicked()), this, SLOT(test()));
    To copy to clipboard, switch view to plain text mode 
    did you add Q_OBJECT macro in your class declaration.
    PS. I've just tested both of these approaches and they work fine for me.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Help needed with QItemDelegate
    By cyberboy in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2008, 19:21
  2. QItemDelegate
    By cyberboy in forum Qt Programming
    Replies: 10
    Last Post: 27th June 2008, 18:41
  3. Return a pointer from a QItemdelegate
    By SailinShoes in forum Qt Programming
    Replies: 5
    Last Post: 12th March 2008, 21:07
  4. premature call to setmodeldata with QItemDelegate
    By placebo in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2007, 18:39
  5. QTextEdit Justify align making work
    By dec0ding in forum Qt Programming
    Replies: 2
    Last Post: 13th January 2006, 13:02

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.