Currently, I have a nested QVBoxLayout in the first column of a QHBoxLayout, but no matter my changes to .setContentMargins or .setSpacing nothing changes in that first column. Leaves me with this result: What I want: Answer Use addStretch() method:
Tag: pyqt
Saving states of QRadioButtons using QSettings not persisting values correctly in PyQt5
I’m baffled by the results of using QSettings to save the state of my radio buttons from one app session to another using PyQt5. (OS = Ubuntu Linux 18.04) These are the steps to produce baffling results: Run the app; see both radio buttons selected; both buttons fire as if mouse selected Deselect the top radio button Close the app;
Cannot populate QTableWidget using .setItem(row, colum, QTableWidgetItem(data))
I wanted to test PyQt to write a quick app to display and edit data in an Excel like form but the data is never shown. Both the docs and the book I read say that using .setItem(row, colum, QTableWidgetItem(data)) on a QtableWidget object is one way to go. However, the following code doesn’t work, I only have an empty
How to align two widgets more closely in PyQt5 layouts?
How to align two widgets more closely? In my code, I want to align QLabel 1 and QLabel 2 more closely (i.e. QLabel 2 aligned just below the QLabel 1, with minimum spacing). Answer I assume what you’re trying to achieve is a double underline for the text in the first label. The problem with your example is that the
Why my PyQt5 Webview Code is not working?
This is my code. Why its not working? Where is my problem? Answer Your code has 2 problems: The QWebEngineView is not a child of the window so it will not be displayed. Change to self.widget = QWebEngineView(Form) QUrl(“google.com”) is not a valid url so you have 2 options, change to: QUrl(“https://google.com”) OR QUrl.fromUserInput(“google.com”)
How to store the last checked item as default, when Opening next time , in PyQt5 QRadioButton?
It’s my code. How to store the lastly clicked/checked button as default in the next opening of the programme? For example: If we run the programme and click the 3rd button and close the entire programme. Whenever I reopen/re-run the programme, the lastly clicked button is checked by default ( ie. third button is checked by default) Answer You can
Multiple context menu in a single qTableView pyqt5
i added two functions in two different pushButtons. for both function i used a common qtableView. i created two contextmenu, whenever user clicked pushButton1 func1 is called and result set will be shown in qtableView and user can select items from contextmenu1 and same like pushButton2 ,where contextMenu2 will appear . but in my code context menu is not showing
pyqtgraph: How to add radiobuttons on a figure legend?
I want to control which curves are displayed at the figure by using the radiobuttons floating on the left-top corner, which will work also as a legend. How can I do that? Answer This could be achieved by inheiring pg.LegendItem and overriding addItem method. In it you need to create widgets and place them into layout. You can use QGraphicsProxyWidget
Combining a file dialog with buttons in PyQt
I’m struggling with making the transition from Tkinter to the more object-oriented approach of PyQt. My particular question focuses on combining file dialogs with buttons. In the example below, having lines of code I admittedly don’t completely understand, I use a file dialog to load a time series, stored as a .csv file, into a dataframe and then plot it: