Results 1 to 6 of 6

Thread: QDialog and Multithreading within PYQT5

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2013
    Posts
    36
    Thanks
    14
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5

    Default Re: QDialog and Multithreading within PYQT5

    First: Thanks for your time. And thanks for the hint with processEvents. That worked! Here I think I was not clear enough in what I wanted to know:
    Quote Originally Posted by d_stranz View Post
    Since you are adding the ui into your dialog class by composition (i.e. there is a "ui" member variable for the Ui_Dialog class), then you access the label as "self.ui.statusLabel".
    I want to get ALL labels of the Ui_Dialog class - something like
    Qt Code:
    1. Ui_Dialog.findChildren(QWidgets.QLabel)
    To copy to clipboard, switch view to plain text mode 
    if I wanted to find all QLabels ... but this only works for the resultWindow method. How does it work on the Ui_Dialog?
    Qt Code:
    1. dir(Ui_Dialog)
    To copy to clipboard, switch view to plain text mode 
    shows no method Children/findChildren.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QDialog and Multithreading within PYQT5

    The documentation for QObject::findChildren() says that the first argument should be a QString that names the type (ie. class) of the widgets you want to retrieve.

    In C++, this is implemented using templates, as the documentation shows. I do not know how this is done in python.

    In addition, you are using the name of your class (Ui_Dialog), not the name of the variable that implements that class in your dialog. So at a minimum, your code should look something like this:

    Qt Code:
    1. self.ui.findChildren( QWidgets.QLabel )
    To copy to clipboard, switch view to plain text mode 

    assuming QWidgets.QLabel is the correct syntax for the argument. Perhaps it should be "QWidgets.QLabel" (ie. a quoted string) instead.

    Or maybe you don't need the "ui" variable at all:

    Qt Code:
    1. self.findChildren( QWidgets.QLabel )
    To copy to clipboard, switch view to plain text mode 

    where "self" is your Dialog class instance.
    Last edited by d_stranz; 22nd March 2020 at 15:52.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Multithreading
    By havij000 in forum Newbie
    Replies: 22
    Last Post: 21st August 2013, 13:35
  2. Replies: 1
    Last Post: 26th March 2013, 02:04
  3. Replies: 9
    Last Post: 25th March 2011, 21:22
  4. QDialog.exec() exiting without calling QDialog::accept()
    By doggrant in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2011, 11:35
  5. regarding multithreading
    By mohanakrishnan in forum Qt Programming
    Replies: 19
    Last Post: 9th December 2009, 08:21

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.