Skip to content

Qt for Python

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

3.3k Topics 14.5k Posts
  • Drop shadow not working

    Unsolved
    21
    0 Votes
    21 Posts
    3k Views
    jsulmJ
    @poppypelt12 It is common mistake to declare a local variable which is destroyed as soon as it goes out of scope. Just be careful when declaring variables and think about scope and life time of objects.
  • PySide6 tutorial application does not have shadow on Wayland on Ubuntu

    Unsolved
    3
    0 Votes
    3 Posts
    515 Views
    R
    @jsulm Nope, nothing.
  • 'color' of QToolTip stylesheet not working

    Unsolved
    4
    0 Votes
    4 Posts
    617 Views
    EbyZeroE
    @SGaist Oh I am using windows 10 pro 22H2 19045.3448 build. You can get the problem through a simple example. import sys from PySide6.QtCore import * from PySide6.QtWidgets import * from PySide6.QtGui import * class mainwindow(QMainWindow): def __init__(self) -> None: super().__init__() layout = QHBoxLayout(self) button = QPushButton("this is a button", self) button.setToolTip("this is a tooltip") button.resize(200, 200) layout.addWidget(button) self.resize(400, 400) self.setStyleSheet("QToolTip { color: red; }") if __name__ == "__main__": app = QApplication(sys.argv) m = mainwindow() m.show() sys.exit(app.exec()) Or can see it by using widget designer of pyside6. In version 6.5.2, you can see that the 'color' of the stylesheet for QToolTip is not working.
  • Multi-line <PRE> in QTextEdit breaks line wrap

    Unsolved
    4
    0 Votes
    4 Posts
    636 Views
    JonBJ
    @MostTornBrain Well done for figuring a workaround. It would be good if you posted a link to your bug report.
  • Drag and drop widgets onto a MS word-like a4 page

    Solved
    12
    0 Votes
    12 Posts
    827 Views
    M
    @SGaist First thing I tried was mapToScene(), but that didn't work. What worked, is defining the sceneRect for the scene. Without it, there apparently are no native coordinates and they get set on the fly with each button drop, with the first drop being dead center in the scene. All I had to do is add the following line: self.graphics_scene = CustomGraphicsScene(parent=self) # ADDED THE FOLLOWING LINE: self.graphics_scene.setSceneRect(0, 0, page_size, int(page_size*math.sqrt(2))) self.graphics_view = CustomGraphicsView(self) There's still some polishing like scrollarea showing the scrollbars, basically just not slightly showing the full rect. If I increase the size of the scrollarea, it doesn't solve it. But that stuff is for worries later on. Thanks anyway, you're a great help!
  • Issue with using QPropertyAnimation with a Timer

    Unsolved
    2
    0 Votes
    2 Posts
    310 Views
    SGaistS
    Hi and welcome to devnet, If you want your box to move freely around, you have to take it out of the layout and manually place it where you want it.
  • Tabs not appearing; what am I doing wrong?

    Unsolved
    5
    0 Votes
    5 Posts
    856 Views
    S
    @JonB - Thanks. I finally got it working. The key was setting the centalWidget to the top_level_tabs widget. Here's the winning code: ship_trade_btn = QPushButton("Text", self) self.top_level_tabs = QTabWidget() self.top_level_tabs.setTabBarAutoHide = False ship_trade_layout = QHBoxLayout(ship_trade_btn) ship_trade_layout.addWidget(ship_trade_btn) self.setCentralWidget(self.top_level_tabs) self.setLayout(ship_trade_layout) self.top_level_tabs.addTab(ship_trade_btn, "Trades") self.centralWidget().show()
  • Image

    Unsolved
    3
    0 Votes
    3 Posts
    236 Views
    SGaistS
    Hi, Use a QTimer to change your image. You can use a list with all your image paths in it and switch on each iteration. Note that you have to take into account the time it takes to load an image.
  • PyQt6 Control keyboard shortcut not working

    Solved
    8
    0 Votes
    8 Posts
    2k Views
    MalonnM
    @SGaist I did. The combo is not spoken for. I'll double check though. I've troubleshot a lot, and can't recall all I've tried to detail in a post here. It still wouldn't explain why I can't get the Ctrl key to print, while other modifiers do. There might not be much people here can do unless I man up and post an MRE. EDIT: Oops! You are right @SGaist . The OS shortcut slipped under the cracks. Alt+F1 is assigned to KWin, and it blocks my app from using it. Damn, wish I would have not missed that earlier—would have saved hours of troubleshooting.
  • 0 Votes
    1 Posts
    233 Views
    No one has replied
  • Menu Actions with variable number of actions

    Solved
    4
    0 Votes
    4 Posts
    316 Views
    SGaistS
    This stack overflow answer shows it nicely. The short version is: bookmarked_url = QUrl("{}".format(self.bookmarkData.Address[i])) action.triggered.connect(lambda url=bookmarked_url: self.parent.go_to_URL(url)) Beware that you are creating objects that can be garbage collected when doing so. I strongly encourage you to refactor your code following my suggestion above.
  • Push Button not displaying on run

    Solved
    5
    0 Votes
    5 Posts
    360 Views
    poppypelt12P
    @JonB my friend, i have no idea myself...
  • Help menu item not showing

    Solved
    7
    0 Votes
    7 Posts
    572 Views
    nicholas_yueN
    @friedemannkleint Thank you. It works. https://github.com/nyue/QtQuestions/blob/main/PySide2/macos_menu_about/main.py#L12
  • QListView IconMode DragDropMode InternalMove not working for me

    Solved qt for python python
    3
    0 Votes
    3 Posts
    441 Views
    L
    I tried using list mode instead and it worked! I have no idea why icon mode doesn't. I don't even need to set DragDropMode to InternalMove in list mode for reordering, as I have set my DefaultDropAction to MoveAction. What I've done instead is to change viewOptions to icon mode settings. class SlotView(QListView): def __init__(self, parent=None): super().__init__(parent) self.setMovement(QListView.Movement.Snap) self.setDefaultDropAction(Qt.DropAction.MoveAction) self.setSelectionMode(QListView.SelectionMode.ExtendedSelection) self.setVerticalScrollMode(QListView.ScrollMode.ScrollPerPixel) self.horizontalScrollBar().setEnabled(False) self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.setIconSize(ICON_SIZE) self.setGridSize(ICON_SIZE) self.setFixedSize(SLOT_SIZE) def viewOptions(self): option = super().viewOptions() option.showDecorationSelected = True option.decorationPosition = QStyleOptionViewItem.Position.Top option.displayAlignment = Qt.AlignmentFlag.AlignCenter return option
  • How to get a boolean value from QSettings correctly?

    Solved
    8
    0 Votes
    8 Posts
    5k Views
    F
    PySide also let's you specify a type: https://doc.qt.io/qtforpython-6/PySide6/QtCore/QSettings.html#PySide6.QtCore.PySide6.QtCore.QSettings.value
  • qhelpgenerator

    Unsolved qt for python
    1
    0 Votes
    1 Posts
    233 Views
    No one has replied
  • Pyside6 application on different screen sizes

    Unsolved
    4
    0 Votes
    4 Posts
    1k Views
    SGaistS
    How many widgets do you have there ? Layouts usually resize their inner widgets down to a minimum when you resize the containing widget.
  • 0 Votes
    1 Posts
    212 Views
    No one has replied
  • Error when building/packaging Pyside6 6.5.1.1

    Solved
    2
    1 Votes
    2 Posts
    507 Views
    Stefan ScherfkeS
    I found the Problem. I configured Qt6.5 with -bindir $PREFIX/bin \ -libdir $PREFIX/lib \ -headerdir $PREFIX/include/qt6 \ -archdatadir $PREFIX/lib/qt6 \ -datadir $PREFIX/share/qt6 \ This caused the modules (and metatypes) directories to be created under $PREFIX/share/qt6/.... However, setup scripts of Pyside6 are hardcoded to use LIB_DIR.parent / "modules" which does not work. I removed the config flags in Qt and it worked.
  • How to handle a threading socket server

    Unsolved
    7
    0 Votes
    7 Posts
    867 Views
    D
    @jeremy_k Ok, I indeed definitely mean SOCK_STREAM. Thanks for clearing that up.