Skip to content

Qt for Python

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

3.3k Topics 14.7k Posts
  • Why does resizeEvent react to changing subwidgets and what to do about it?

    Unsolved
    1
    0 Votes
    1 Posts
    278 Views
    No one has replied
  • How can I resize the Tiff Image without compromising its quality?

    Unsolved
    5
    0 Votes
    5 Posts
    981 Views
    N
    @qwasder85 I'm grateful for the solution you shared; it worked perfectly. Thank you!
  • Hide title/application bar in python Pyside6

    Solved
    16
    0 Votes
    16 Posts
    5k Views
    poppypelt12P
    @JonB Lol!! :-)) its an app for nursing homes
  • Reliable position to pop context menus for tray icon on left click with Wayland

    Unsolved
    4
    0 Votes
    4 Posts
    773 Views
    F
    There is a restriction in Wayland in that the standard protocol that does allow positioning windows (see https://bugreports.qt.io/browse/QTBUG-110119 ).
  • PyQt6 QtDBus How to Create Method Call

    Unsolved
    2
    0 Votes
    2 Posts
    483 Views
    MalonnM
    I had posted this on StackOverflow back in July as well, and I received an answer today. I'll just link to the answer, which I haven't tested because I am in the middle of a different project. There are a couple good comments as well, so a link would be more prudent, I believe. StackOverflow
  • Drop shadow not working

    Unsolved
    21
    0 Votes
    21 Posts
    7k 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
    767 Views
    R
    @jsulm Nope, nothing.
  • 'color' of QToolTip stylesheet not working

    Unsolved
    4
    0 Votes
    4 Posts
    837 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
    889 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
    2k 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
    404 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
    1k 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
    416 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
    312 Views
    No one has replied
  • Menu Actions with variable number of actions

    Solved
    4
    0 Votes
    4 Posts
    535 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
    746 Views
    poppypelt12P
    @JonB my friend, i have no idea myself...
  • Help menu item not showing

    Solved
    7
    0 Votes
    7 Posts
    927 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
    550 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
    6k 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