Results 1 to 11 of 11

Thread: Shopping list type of program: how to move bought items to the bottom of QTreeWidget?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: Shopping list type of program: how to move bought items to the bottom of QTreeWid

    Quote Originally Posted by weeezes View Post
    I don't know how to create a new signal for an object to emit.
    Nothing easier! In your header file, include the following section:

    Qt Code:
    1. signals:
    2. void yourSignal(); // can also have parameters
    3. ...
    4. //rest of class
    To copy to clipboard, switch view to plain text mode 

    That's it! (Well ok, they can be declared as protected etc., but that can come later). There is no "definition" of signals in the .cpp file, and their return type must be void. Then, in the .cpp file, you will have the following:

    Qt Code:
    1. retType yourClass::yourFunction(yourParams)
    2. {
    3. ...
    4. emit yourSignal();
    5. ...
    6. return ...;
    7. }
    To copy to clipboard, switch view to plain text mode 

    The emit statement is often located near or at the end of a function. So now an object of type yourClass will emit yourSignal() whenever yourFunction() is called, and that object can be meaningfully connected to a slot.

    Hope this helps!

  2. The following user says thank you to Urthas for this useful post:

    weeezes (29th August 2010)

  3. #2
    Join Date
    Aug 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Symbian S60

    Default Re: Shopping list type of program: how to move bought items to the bottom of QTreeWid

    Wow, thank you very much, Urthas! That's exactly what I was strugling to find! That seems so simple that I almost feel embarassed that I ever asked about it . The emit statement is a new thing for me, maybe it's a so short word that I have missed it completely . Let's see if I get something done with this new skill of mine >...

    Thank you again .

Similar Threads

  1. Move items up and down in QListWidget
    By araglin in forum Newbie
    Replies: 7
    Last Post: 31st August 2016, 11:05
  2. List all elements of a QTreeWidget from top to bottom
    By ricardosf in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2010, 02:46
  3. getting a file extenstion list from a MIME type
    By roxton in forum Qt Programming
    Replies: 0
    Last Post: 10th April 2009, 18:27
  4. Replies: 1
    Last Post: 22nd November 2008, 06:32
  5. Can't move Items in the scene
    By maverick_pol in forum Qt Programming
    Replies: 2
    Last Post: 16th May 2008, 09:40

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
  •  
Qt is a trademark of The Qt Company.