Results 1 to 6 of 6

Thread: Adding slots in Designer

  1. #1
    Join Date
    May 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Adding slots in Designer

    I'm in the proces of evaluating Qt 4.1.2 for a project that was originally written in MFC.. and I'm trying to wrap my head around things. I'm working in Visual Studio 2005; for my test I'm building a simple app with some combo boxes.

    At the moment I am puzzled as to how to add slots to my window class. Designer does not seem to have any facility to add slots to a class (am I missing something?) So I have to add them by hand. However -

    - If I manually add slots to my class (QtTest, derived from QMainWindow), the slots do not show up in Designer, so I can't use Designer's signal/slot facilities.

    - If I were to add the slots to ui_QtTestClass, then they will be overwritten the next time I edit the form in Designer - am I correct?

    I must be missing something; there's no point in having all this signal/slot support in Designer if there's no way to add slots through Designer...

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Adding slots in Designer

    Quote Originally Posted by jamos
    At the moment I am puzzled as to how to add slots to my window class. Designer does not seem to have any facility to add slots to a class (am I missing something?) So I have to add them by hand.
    Yes, you have to add them by hand.

    Quote Originally Posted by jamos
    - If I manually add slots to my class (QtTest, derived from QMainWindow), the slots do not show up in Designer, so I can't use Designer's signal/slot facilities.
    True, you would have to create a custom widget plugin for the designer.

    Quote Originally Posted by jamos
    - If I were to add the slots to ui_QtTestClass, then they will be overwritten the next time I edit the form in Designer - am I correct?
    Correct. You are not supposed to modify headers generated by uic.
    J-P Nurmi

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding slots in Designer

    A general approach for Qt4 is to design your user interfaces in Qt Designer and then either inherit or incorporate them in a regular C++ class derived from one of QWidget descendants and use the designed UI by calling setupUi().

    Qt Code:
    1. class MyMainWindow : public QMainWindow, private Ui::MyMainWindow {
    2. //...
    3. };
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. class MyMainWindow : public QMainWindow {
    2. //...
    3. private:
    4. Ui::MyMainWindow ui;
    5. //...
    6. };
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    May 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Adding slots in Designer

    Wow. This essentially makes Designer worthless except as a layout tool.

    OK. I'll swim with that. Thanks.
    Last edited by jamos; 12th May 2006 at 16:06.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding slots in Designer

    It is strictly a layout tool (of course you can manage signals and slot connections there too) and not an IDE.

  6. #6
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Adding slots in Designer

    Indeed, QtDesigner simply integrates into Visual Studio 2005, and piggy-backs off of Microsoft's debugger, compiler, etc. Visual Studio 2005 is still your IDE.
    Software Engineer



Similar Threads

  1. Creating slots in Designer
    By Cruz in forum Qt Tools
    Replies: 1
    Last Post: 17th February 2009, 19:08
  2. Jambi - Eclipse - Designer - Slots
    By ronnyf in forum Newbie
    Replies: 2
    Last Post: 2nd February 2009, 15:35
  3. Replies: 12
    Last Post: 23rd June 2008, 08:05
  4. Adding scrollbars from within Designer
    By MrGarbage in forum Qt Tools
    Replies: 1
    Last Post: 3rd September 2007, 19:35
  5. Replies: 2
    Last Post: 12th July 2007, 09:55

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.