Results 1 to 3 of 3

Thread: Can not cast into the derived class from QScrollBar

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Can not cast into the derived class from QScrollBar

    I defined a class ViewScrollBar derived from QScrollBar. There is also a public slot: void currentValue(i nt value); I hope to use this slot in another class.
    Qt Code:
    1. #include <QScrollBar>
    2. class ViewScrollBar: public QScrollBar
    3. {
    4. Q_OBJECT
    5. public:
    6. ViewScrollBar();
    7. ~ViewScrollBar();
    8. int getCurrentValue();
    9.  
    10. public slots:
    11. void currentValue(i nt value);
    12.  
    13. private:
    14. int currentPos;
    15. };
    To copy to clipboard, switch view to plain text mode 

    Then I get the scroll bar from the QGraphicsView by the method:
    ViewScrollBar *hScrollBar=static_cast<ViewScrollBar*>(graphicsVi ew->horizontalScrollBar());

    I connect the signal valueChanged() from QScrollBar with my public slot currentValue(i nt value) in ViewScrollBar class.
    connect(hScrollBar, SIGNAL(valueChanged(int)),hScrollBar, SLOT(currentValue(int)));

    when I run, there is always warning that:
    Object::connect: No such slot QScrollBar::currentValue(int).
    The object hScrollBar is ViewScrollBar now. But it is still regarded as its parent class. How can cast it from QScrollBar to ViewScrollBar?
    Last edited by wysota; 19th December 2008 at 08:20. Reason: missing [code] tags

Similar Threads

  1. no frame on Qlabel derived class
    By tupu_83 in forum Qt Programming
    Replies: 2
    Last Post: 19th November 2008, 16:01
  2. Use QWidget derived class in Dialog
    By qtneuling in forum Qt Tools
    Replies: 2
    Last Post: 17th May 2008, 23:29
  3. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  4. Replies: 2
    Last Post: 20th September 2007, 12:27
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36

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.