Results 1 to 6 of 6

Thread: Playbutton functionality

  1. #1

    Default Playbutton functionality

    I am going to do my best explaining the problem at hand:

    I am trying to develop existing code. When the program finishes loading there are two widgets on the screen, one that I dont care about and can simple cancel from the screen and the other that I am concered about. Basically my goal is to press a button (play button) and data will be read from a text file, placed into memory, and then the widget on the screen will be repainted, displaying the changes. This process will be repeated over and over again until a button like stop is pressed. That's the idea of the program.
    So far, I have created a QPlayback .h and .cpp files to work with the overall program. In my MainWindow .cpp 's constructor, I called the "new" operator to create the button that is a play button. In the contructor for the QPlayback .h, I want to connect the buttons clicked( ) from 'this' to the repaint of the widget on the screen.
    My confusion is this: first, I do not know which object to use in the connect function to allow the button, the playbutton that is, to take control of the widget. I have read some other posts and I am confused with this process of repaint( ) and update( ). Please do help further ? Given the above scenario, how would I develop such a button, what should I keep in mind when developing play, fast-forward, pause, stop, like a tape player...

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Playbutton functionality

    Take a look at QTimer class.

  3. #3

    Default controlling a visual widget from a button

    I have a program that I am developing. I do not understand how I can take control of the display widget that is controlled by a class that has event handlers. I know for sure that this class is controlling the visual widget; however, I cannot gain control of it the way I want to. I also have created a QPlayback class that has several buttons. I'd like one of those buttons to control the visual widget through some sort of signal and slot process; however, there is no slot in the class that controls the visual widget. I know that this class controls the visual widget because I debugged the code and found that whenever I pressandrelease on the display widget then the debugger ends up in a function (repaint(PaintEvent* ) in class (MapVisual, which is not a QMapVisual and not derived from QWidget). All that I want to do is simply press this button from one widget and repaint the map on the other widget and it is becoming a nightmare. I reasoned if I send a click signal from the qplayback to a slot on the qplay back and within this slot function, call the repaint function in the class that control the widget, I can repaint the screen whenever I want to. This doesn't seem to work because I have to declare an event in the slot function and sent it as a parameter to the recieving function, but that doesn't work because the QPaintEvent declaration is NULL! How do I got about fixing my issue ?? I can explain further if you guys need me to...

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: controlling a visual widget from a button

    Quote Originally Posted by uchennaanyanwu View Post
    All that I want to do is simply press this button from one widget and repaint the map on the other widget and it is becoming a nightmare.
    Then all you need is to connect button's clicked() signal to the update() slot of that other widget. Provided that you haven't blocked the event loop, Qt should handle the rest.

  5. #5

    Default Re: Playbutton functionality

    thanks for the reply....It isn't declared as a slot. Moreover, the class called MapVisual isn't derived from a QWidget at all, instead it is from Visualizer, which is not a QWidget? It has paintEvent(QPaintEvent *e), dragEnter(QDragEvent *e), and etc. Any ideas ??

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Playbutton functionality

    Quote Originally Posted by uchennaanyanwu View Post
    Moreover, the class called MapVisual isn't derived from a QWidget at all, instead it is from Visualizer, which is not a QWidget?
    These aren't Qt classes. Do you use any 3rd party libraries?

Similar Threads

  1. Replies: 3
    Last Post: 1st April 2011, 05:58
  2. portable getopt() functionality
    By KShots in forum Qt Programming
    Replies: 7
    Last Post: 14th March 2011, 19:19
  3. Functionality Of Qsciptengine file
    By Gaurav K SIngh in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd July 2007, 11:50
  4. spy++ like functionality with Qt / X11
    By bpetty in forum Newbie
    Replies: 3
    Last Post: 24th April 2007, 23:10
  5. Replies: 13
    Last Post: 15th December 2006, 12:52

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.