Skip to content

Qt for Python

For discussion and questions about Qt for Python (PySide & Shiboken)

3.3k Topics 14.5k Posts
  • Designer can't find uic

    Unsolved
    6
    0 Votes
    6 Posts
    5k Views
    D
    Sorry for digging out this post but I've just installed PySide6 and had similar problem with pyside6-designer launched from command line. I have temporary fixed it by making a link to venv\Lib\site-packages\PySide6\ inside that folder called bin. mklink /D "bin" "c:\******\******\*******\venv\Lib\site-packages\PySide6"
  • How do you write shiboken binding if additional snippets should be added?

    Solved
    2
    0 Votes
    2 Posts
    244 Views
    SGaistS
    Hi, To the best of my knowledge, there's currently no such things.
  • Clear selection - no work

    Unsolved
    2
    0 Votes
    2 Posts
    242 Views
    SGaistS
    Hi and welcome to devnet, Can you explain why you are abusing "parent" as you do ? Also, what exactly are you trying to achieve ? It seems that the QGraphicsElipseItem would do what you need.
  • Remove Duplicates from Array in Python

    Unsolved
    3
    0 Votes
    3 Posts
    4k Views
    JonBJ
    @Aliviya Hi. This forum is not necessarily the best for generic Python questions. Either of your techniques is standard. set() might be the most efficient. If you are using numpy it offers a NumPy: numpy.unique() function to save you writing the code.
  • Unable to set "QMainWindow" shadow with "FramelessWindowHint" window type

    Unsolved
    7
    0 Votes
    7 Posts
    821 Views
    bashtianB
    @mpergand I did try it but it has no effect on the shadow, when added to the QMainWindow flags
  • Cannot resize QPlainTextEdit

    Moved Unsolved
    3
    0 Votes
    3 Posts
    311 Views
    G
    @mpergand it doesn't work for me, because I want to make an animation for QPlainTextEdit, which will exactly change its height (something like a dropdown widget animation), and setMinimumHeight() won't let me change the height to 0.
  • First Qt Python project

    Unsolved
    16
    0 Votes
    16 Posts
    3k Views
    A
    I do appreciate you taking time for reply. However, you may not be aware that what I was trying to do is not “normal”. As a user of C++ QtCreator /QtDesiger I did expected that I can modify existing Python application using QtDesigner. That just did not work and it is not a “big deal” ( to me) that it does not. There are other Qt issues which could use some attention and hopefully a resolution. However, I feel this is is not the place to discuss that, and most of them have been “reported” as bug(s) anyway.
  • Maintaining Consistent Font Appearance in PySide6 QLabel: QSS vs. QFont

    Moved Solved qfont label qlabel
    11
    0 Votes
    11 Posts
    4k Views
    JonBJ
    @Emrecp I believe @SGaist is telling you that you cannot guarantee that a widget with a stylesheet will look identical to one you construct with coded style attributes. As soon as you place a stylesheet on a widget you are (potentially) losing some styles which are inbuilt, so it may differ. I suggested earlier you remove the weight stuff in your example and see whether just with the font in "normal" it does or does not look identical using the same font in both code and stylesheet. If you are coding inside paintEvent() then, as you say, you cannot use stylesheet. You can only set the attributes on a QFont as you have done. I don't know whether you can go through the sources of Qt to discover just what a current style like Fusion does.
  • 0 Votes
    2 Posts
    877 Views
    JonBJ
    @LT-K101 said in How to connect pyqt5 desktop application to an sql server management studio database on a different computer.: connection_string = f'DRIVER=SQL Server;SERVER={server};DATABASE={database};UID={username};PWD={password}' I trust this is not actually the literal string you pass, is it? [OIC, you have defined the Python variables for interpolation, got it.] Your code is 100% Python with its internal database connection library. You do not use Qt or Qt's SQL database library here, so your question would best be addressed to a Python forum rather than a Qt one. P.S. DRIVER=SQL Server Are you sure this correct? Where did you copy this from? You sure it wasn't supposed to be DRIVER={SQL Server} Even then I'm not sure whether SQL Server isn't a very old name to use for the driver? Otherwise various suggestions in, say, https://stackoverflow.com/questions/46045834/pyodbc-data-source-name-not-found-and-no-default-driver-specified or other hits by Googling the error message. Finally, just to make sure: the MS SQL Server you want to connect to on the server is running a default instance of MSSQL Server, right? Not a named instance?
  • Get incorrect widget size by window handle

    Unsolved
    13
    0 Votes
    13 Posts
    2k Views
    Axel SpoerlA
    Nontheless, to conclude this thread somehow: FramlessWindowHintis a hint and doesn't guarantee that window is really rendered frameless. Native handles seem to get rendered in the case at hand. The pixel difference represents their size. Given that my proposed way to confirm it doesn't work out in Python, looking at the physical window on the screen is the only way to confirm.
  • QListWidget expand height dynamically

    Unsolved python qt for python
    4
    0 Votes
    4 Posts
    902 Views
    S
    @Emrecp, I don't think my code would be any better then "an official one". So I would propose you to review a Fetch More Example
  • In PySide6, why assignment before super().__init__() might lead to abnormal result?

    Unsolved
    2
    0 Votes
    2 Posts
    375 Views
    JonBJ
    @isaacchangwang said in In PySide6, why assignment before super().__init__() might lead to abnormal result?: It seems super().init() must be called first in the initialization method, otherwise it might lead to abnormal result. Is that true? I would always expect to have to call the base super().__init__() as the first statement in any derived class, whether Qt/QObject or not. Putting a QObject/QTimer into a derived class as a member before it has been initialised does not sound like a good idea.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    20 Views
    No one has replied
  • How to write text to listWidget?

    Unsolved
    2
    0 Votes
    2 Posts
    207 Views
    JonBJ
    @AnneRanch said in How to write text to listWidget?: self.pushButton_InitializeTRACE.clicked.connect(self.listWidget.addItem(self.item_TEST) ) Try: self.pushButton_InitializeTRACE.clicked.connect( lambda: self.listWidget.addItem(self.item_TEST) ) You need a lambda here for the slot, that's how you specify inline code like you have to execute rather than connecting to a method.
  • EDITED How to verify "show" ?

    Unsolved
    10
    0 Votes
    10 Posts
    863 Views
    A
    @JonB I am running the Python code in debug mode and I have few debug "flags" in my code. The "problem" is with my little knowledge how Python works. If I set a breakpoints inside class and run it will stop at the breakpoints, which is good, but it does not actually execute the class GUI code. It sort of verify the code flow... I will add some "button pushed" code to dig into this .
  • PyQt Multi Language problem

    Moved Solved
    14
    0 Votes
    14 Posts
    3k Views
    H
    I finally found the solution. Do not need retranslateUi() in QDialog because if the translations exist, and the translation is loaded correctly, when create new Dialog (show() or exec() action), it will also show the appropriate translated text. My error was loading wrong QTranslator in QApplication. In QMainWindow, this is my correct code: translator variable must use in both if name function and in body of QMainWindow. Earlier I made the mistake of instantiating a new QTranslator in the body of the QMainWindow (change_language() fuction) and using it to load the new language, so it was out of sync with the original QTranslator in the name function. def change_language(self): current_language = None if LanguageQSettings().get_current_language() == Style.Language.vie: # Set tieng Anh o day current_language = Style.Language.en else: # Set tieng Viet o day current_language = Style.Language.vie translator.load(current_language) app.installTranslator(translator) self.retranslateUi() LanguageQSettings().set_current_language(current_language) def retranslateUi(self): self.home_screen.retranslate_Ui() if not self.login_screen.deleteLater: self.login_screen.retranslateUi_login() self.update() if __name__ == "__main__": app = QApplication(sys.argv) translator = QTranslator() translator.load(LanguageQSettings().get_current_language()) app.installTranslator(translator) app.setWindowIcon(QIcon(Style.Image.icon128)) app.setApplicationName(Style.Text.app_name) widget = MainWindow() widget.show() sys.exit(app.exec())```
  • Label help

    Unsolved
    7
    0 Votes
    7 Posts
    573 Views
    jsulmJ
    @nick_d12 Please use code tags correctly, especially when posting Python code. Is the font you're setting in QFont really the same used in the label? And what is the value get_font_metrics returns? Also, "that did not work" is not a proper problem description. In what way it did not work? Is the calculated height to big or to small?
  • update loop

    Unsolved
    2
    0 Votes
    2 Posts
    200 Views
    jsulmJ
    @nick_d12 Update what? QTimer has a signal https://doc.qt.io/qt-6/qtimer.html#timeout simply connect a slot to it and do whatever you need in that slot.
  • Environment variable PYSIDE_DESIGNER_PLUGINS is not set, bailing out

    Unsolved
    3
    1 Votes
    3 Posts
    5k Views
    F
    We made a change to silence the warning; it is only relevant for Qt Designer ( https://codereview.qt-project.org/c/pyside/pyside-setup/+/494171 ).
  • 0 Votes
    4 Posts
    335 Views
    JonBJ
    @zhyemqww You may not like to hear this, especially being a Python developer, but I wonder if you might look at the source of how Qt positions the header's rows/columns to see if you can figure from that why it is "out of sync" wrt the content rows/columns.