Results 1 to 5 of 5

Thread: Qt Creator: connecting actions trigged to slots

  1. #1
    Join Date
    Apr 2015
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Qt Creator: connecting actions trigged to slots

    I've started a small project in PyQt5. I've used Qt Creator to design the UI for the Main Window, and converting the .ui file by using the pyuic5 tool for use with my python code, which I write in PyCharm. It worked fine for a couple of days, but I ran into a bit of trouble when I added toolbar buttons. So first things first:

    - Is Qt Designer nowadays built-in Qt Creator, or am I using the wrong application? (there a lot of instructions to use Designer everywhere on the web, I can't find it)

    I ran into trouble when I wanted to connect an action for a toolbar button to a slot. I can create the action in Qt Creator, but the slot I want to use is not familiar to Qt Creator since it's written in PyCharm, outside the project from Qt Creators point of view. The slot is in the MainWindow class, but Qt Creator does not know that and I can't select it from the drop down list. Any suggestions?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Creator: connecting actions trigged to slots

    Quote Originally Posted by ecce View Post
    I
    - Is Qt Designer nowadays built-in Qt Creator, or am I using the wrong application? (there a lot of instructions to use Designer everywhere on the web, I can't find it)
    It is available both as a stand-alone tool as well as integrated in QtCreator.
    Since you are using a different IDE than QtCreator, just keep using the stand-alone version.

    Quote Originally Posted by ecce View Post
    I
    I ran into trouble when I wanted to connect an action for a toolbar button to a slot. I can create the action in Qt Creator, but the slot I want to use is not familiar to Qt Creator since it's written in PyCharm, outside the project from Qt Creators point of view. The slot is in the MainWindow class, but Qt Creator does not know that and I can't select it from the drop down list. Any suggestions?
    Just don't connect in QtDesigner, connect in code.
    I would recommend the same thing if you were using C++, btw

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    ecce (20th April 2016)

  4. #3
    Join Date
    Apr 2015
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Creator: connecting actions trigged to slots

    It is available both as a stand-alone tool as well as integrated in QtCreator.
    Where do I find the Qt Designer as a stand alone application? I can find a lot of stuff to download on http://www.qt.io/download-open-source/ but there is no explicit link for the designer as far as I can see.

    Just don't connect in QtDesigner, connect in code.
    That's what I tried to do first. According to the hierarchy on the top right in QtCreator, I have MainWindow (QMainWindow) ->toolBar (QToolBar) ->actionScan (QAction). So I wrote this line of code:

    Qt Code:
    1. self.toolBar.actionScan.trigged.connect(scan)
    To copy to clipboard, switch view to plain text mode 

    and I got this when I run the code: AttributeError: 'QToolBar' object has no attribute 'actionScan'
    Last edited by ecce; 20th April 2016 at 20:31.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Creator: connecting actions trigged to slots

    Quote Originally Posted by ecce View Post
    Where do I find the Qt Designer as a stand alone application? I can find a lot of stuff to download on http://www.qt.io/download-open-source/ but there is no explicit link for the designer as far as I can see.
    Should be part of the normal Qt installer.
    Check the bin directory.

    Quote Originally Posted by ecce View Post
    That's what I tried to do first. According to the hierarchy on the top right in QtCreator, I have MainWindow (QMainWindow) ->toolBar (QToolBar) ->actionScan (QAction). So I wrote this line of code:

    Qt Code:
    1. self.toolBar.actionScan.trigged.connect(scan)
    To copy to clipboard, switch view to plain text mode 

    and I got this when I run the code: AttributeError: 'QToolBar' object has no attribute 'actionScan'
    All the actions are top level elements themselves, they are then plugged into different UI elements, e.g. toolbars, menus.

    Cheers,
    _

  6. #5
    Join Date
    Apr 2015
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Qt Creator: connecting actions trigged to slots

    OK, I got it working (it hit me I could easily see that by put a debug breakpoint an examine what's going on....)

    No trace whatsoever of qt designer as far as I can see... but it does not matter, qt creator works fine.

    Thanks!
    Last edited by ecce; 21st April 2016 at 21:38.

Similar Threads

  1. Connecting many SIGNALS to SLOTS
    By Alex22 in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2015, 10:31
  2. connecting Pop up Menu List to actions/functions
    By ebsaith in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2013, 08:43
  3. Connecting QML signals with Qt slots
    By KIBSOFT in forum Qt Quick
    Replies: 1
    Last Post: 15th November 2010, 10:18
  4. Connecting custom class actions
    By Toshikazu in forum Qt Programming
    Replies: 3
    Last Post: 15th October 2009, 16:31
  5. Connecting to Undeclared Slots
    By Dumbledore in forum Qt Tools
    Replies: 5
    Last Post: 11th October 2007, 18:19

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.