Results 1 to 9 of 9

Thread: Custom Widget - First Steps

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Custom Widget - First Steps

    Been trying to create a custom tab widget that will auto-fill itself with a user-definable number of Faders.. each fader being a custom widget composed of a few buttons and a slider. I'm not really sure how to get started at defining a custom widget though. I've read the docs concerning the "vcr" example, but I can't find the original sources for the example. They say:

    Qt Code:
    1. Vcr::Vcr( QWidget *parent, const char *name )
    2. : QWidget( parent, name )
    3. {
    4. QHBoxLayout *layout = new QHBoxLayout( this );
    5. layout->setMargin( 0 );
    6.  
    7. QPushButton *rewind = new QPushButton( QPixmap( rewind_xpm ), 0, this, "vcr_rewind" );
    8. layout->addWidget( rewind );
    To copy to clipboard, switch view to plain text mode 

    We create a QHBoxLayout in which we'll place the buttons. We've only shown the rewind button in the code above since all the others are identical except for the names of the buttons, pixmaps and signals. For each of the buttons we require we call the QPushButton constructor passing it the appropriate embedded pixmap. We then add it to the layout. Finally we connect the button's clicked() signal to the appropriate signal. Since the clicked() signals aren't specific to our widget we want to emit signals that reflect the widget's use. The rewind(), play(), etc. signals are meaningful in the context of our widget so we propagate each button's clicked() signal to the appropriate widget-specific signal.

    I dont understand, though, which part of that code composes the "signal" aspect.. as I see no "emit" or "connect" or anything of the sort.
    Could someone perhaps give me an example of a qpushbutton ("Foo"), that will cause the parent container to give a "button1-presseddown" signal when it is pressed? I dont need custom pixmaps or anything, I just need a way to get three or four widgets into one container, and to be able to receive signals from the container instead of the individual buttons.

    Thank you
    Last edited by jpn; 19th June 2008 at 04:35. Reason: changed [quote] to [code] tags

Similar Threads

  1. resizing events of a custom widget in a layout
    By Rooster in forum Qt Programming
    Replies: 7
    Last Post: 16th February 2008, 10:52
  2. Custom widget
    By zorro68 in forum Qt Programming
    Replies: 7
    Last Post: 28th January 2008, 14:06
  3. custom plug-in widget in another custom plug-in widget.
    By MrGarbage in forum Qt Programming
    Replies: 6
    Last Post: 27th August 2007, 15:38
  4. Simple custom widget won't size properly
    By MrGarbage in forum Qt Tools
    Replies: 2
    Last Post: 9th August 2007, 13:12
  5. Custom tab widget question
    By PrimeCP in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 11:17

Tags for this Thread

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.