Results 1 to 2 of 2

Thread: why do I need to manualy edit .ui to make Mainwindow slot visible to other senders

  1. #1
    Join Date
    Jul 2008
    Location
    EU , Poland, Zabrze
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default why do I need to manualy edit .ui to make Mainwindow slot visible to other senders

    I use Qt Creator for majority of signal-to-slot assignments

    In the case of having 2 buttons in MainWindow , with very similar actions I wanted the second of the buttons to trigger the button1-on-click slot of the first one.

    Then in the on_click slot I would distinguish by sender()->ObjectName

    I used to to this many times - now ( maybe new qt creator version) I cannot see the slot of the first slot in the Mainwidow slots list.
    I edited mainwidow.h to move the button1-on-click slot to 'public slots' of MainWindow and rebuilt the project but still this slot did not appear in the list of MainWindows slots .

    I found that on the bottom of MainWindow.ui there's a section :
    </connections>
    <slots>
    <slot>something-on-click()</slot>
    </slots>
    </ui>

    By manualy adding <slot>button1-on-click()</slot> to this section I finally got this slot to appear i the list of MainWindow slots i the "signal/slot" editor.

    Why do I need to manually add it - I think in the older QT creator I could see all MainWindow slots by default eve without taggint them as public slots in the header file.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: why do I need to manualy edit .ui to make Mainwindow slot visible to other sender

    1. UI file does not know anything about H file.
    2. Rename slot to on_button1_clicked and read about QMetaObject::connectSlotsByName.
    3. Don't edit manualy UI files.

Similar Threads

  1. Replies: 2
    Last Post: 7th February 2016, 13:12
  2. Replies: 10
    Last Post: 7th December 2011, 21:05
  3. Replies: 1
    Last Post: 29th April 2011, 09:14
  4. Replies: 2
    Last Post: 19th August 2008, 09:46
  5. Replies: 4
    Last Post: 24th March 2006, 22:50

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.