How to delete QFrame in pyqt
By : Alfio
Date : March 29 2020, 07:55 AM
around this issue Deleting or removing the other frames is probably the wrong approach. It's much more efficient to simply hide/show the frames as needed. There are several ways to achieve this, but a QStackedLayout sounds like the best fit for your puposes. All you need to do is add each set of frames as a separate layer/page in the stack, then use setCurrentIndex to bring the required item to the top. A stacked-layout is just like a tab-widget, but without the tab-bar and outer frame. code :
from PyQt4 import QtCore, QtGui
class Window(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
def make_frame(text, parent):
frame = QtGui.QFrame(parent)
frame.setFrameStyle(QtGui.QFrame.StyledPanel)
layout = QtGui.QHBoxLayout(frame)
label = QtGui.QLabel(text, frame)
label.setAlignment(QtCore.Qt.AlignCenter)
layout.addWidget(label)
return frame
self.splitter = QtGui.QSplitter(self)
for text in 'ONE TWO THREE'.split():
self.splitter.addWidget(make_frame(text, self.splitter))
self.stack = QtGui.QStackedLayout()
self.stack.addWidget(self.splitter)
self.stack.addWidget(make_frame('FOUR', self))
self.button = QtGui.QPushButton('Switch', self)
self.button.clicked.connect(
lambda: self.stack.setCurrentIndex(
int(self.stack.currentIndex() == 0)))
layout = QtGui.QVBoxLayout(self)
layout.addLayout(self.stack)
layout.addWidget(self.button)
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
window = Window()
window.setGeometry(500, 300, 800, 500)
window.show()
sys.exit(app.exec_())
|
How the layout adapt to content horizontally and vertically?
By : user3408689
Date : March 29 2020, 07:55 AM
wish helps you Think about GridView, Refer to Android DeveloperYou should define grid view container in your_layout.xml code :
<your.package.ButtonsGridView
android:id="@+id/buttonsGridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" />
ButtonsGridView buttonsGridView = (ButtonsGridView) findViewById(R.id.buttonsGridView);
ButtonsAdapter buttonsAdapter = new ButtonsAdapter(Context);
buttonsGridView.setAdapter(buttonsAdapter);
|
Trouble Getting UITextViews to Adapt to content Using Auto-Layout while Embedded in UIScrollView
By : user3434738
Date : March 29 2020, 07:55 AM
should help you out A better way to do this would be to use a static UITableView. I showed an example of how to do this with code and screenshots on my blog.
|
How to make our layout adapt with our screen devices in android?
By : jif86
Date : March 29 2020, 07:55 AM
Hope that helps Firstly i strongly recommended you to go through the android developer docs for How to support multiple screen in Android and Supporting Different Screen SizesComing to your question, For Different screen size, The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens. you could use different size of the layout files in res folder and also vary for drawable images based on the density.. code :
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation
|
Adding a Qframe in PYQT and set size
By : breuerio
Date : March 29 2020, 07:55 AM
wish of those help You created a frame but never add it to any layout, so it doesn't show. QMainWindow comes with a predefined layout with a menu bar, toolbar, status bar etc ( Qt Doc). To show the frame you could just do self.setCentralWidget(self.frame), it would be inserted in the main window layout. code :
class gameWindow(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setGeometry(300,300,1280,800)
self.frame = QtGui.QFrame()
self.frame.resize(300,300)
self.frame.setStyleSheet("background-color: rgb(200, 255, 255)")
layout=QtGui.QVBoxLayout()
layout.addWidget(self.frame)
self.setLayout(layout)
|