Попробуйте пользовательский Comparator
, например:
Arrays.sort(myarray, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return Integer.valueOf(o1).compareTo(Integer.valueOf(o2));
}
});
Надеюсь, вам понравится!
Проблема вызвана тем, что макеты не используются в RantContainer
. Также желательно установить ограничения в rant-content
вместо rant-container
.
class RantContainer:
def __init__(self):
# Bad idea to subclass widget because it breaks painting
# i.e. the background color goes bye bye
# I'd love to. I really would. But just no.
container = QtWidgets.QWidget()
container.setObjectName("rant-container")
self.container = container
rant_content = QtWidgets.QLabel()
rant_content.setObjectName("rant-content")
rant_content.setWordWrap(True)
# rant_content.setFont(rant_font)
self.rant_content = rant_content
rant_content.setFixedWidth(600) # <---
rant_content.setMinimumHeight(150) # <---
upvote_btn = QtWidgets.QPushButton()
upvote_btn.setObjectName("upvote-btn")
# upvote_btn.setFont(vote_button_font)
upvote_btn.setText("++")
self.upvote_btn = upvote_btn
downvote_btn = QtWidgets.QPushButton()
downvote_btn.setObjectName("upvote-btn")
# downvote_btn.setFont(vote_button_font)
downvote_btn.setText("--")
self.downvote_btn = downvote_btn
score_label = QtWidgets.QLabel(alignment=QtCore.Qt.AlignCenter)
score_label.setObjectName("rant-score")
score_label.setText("69")
# score_label.setFont(score_font)
self.score_label = score_label
vlay = QtWidgets.QVBoxLayout()
vlay.addWidget(upvote_btn)
vlay.addWidget(score_label)
vlay.addWidget(downvote_btn)
vlay.addStretch()
hlay = QtWidgets.QHBoxLayout(container)
hlay.addLayout(vlay)
hlay.addWidget(rant_content)
QSS:
QWidget#rant-container{
background-color: white;
}
QWidget#rant-container:hover{
background-color: #f2f2f2;
}
Или:
class RantContainer:
def __init__(self):
# Bad idea to subclass widget because it breaks painting
# i.e. the background color goes bye bye
# I'd love to. I really would. But just no.
container = QtWidgets.QWidget()
container.setObjectName("rant-container")
self.container = container
rant_content = QtWidgets.QLabel()
rant_content.setObjectName("rant-content")
rant_content.setWordWrap(True)
# rant_content.setFont(rant_font)
self.rant_content = rant_content
upvote_btn = QtWidgets.QPushButton()
upvote_btn.setObjectName("upvote-btn")
# upvote_btn.setFont(vote_button_font)
upvote_btn.setText("++")
self.upvote_btn = upvote_btn
downvote_btn = QtWidgets.QPushButton()
downvote_btn.setObjectName("upvote-btn")
# downvote_btn.setFont(vote_button_font)
downvote_btn.setText("--")
self.downvote_btn = downvote_btn
score_label = QtWidgets.QLabel(alignment=QtCore.Qt.AlignCenter)
score_label.setObjectName("rant-score")
score_label.setText("69")
# score_label.setFont(score_font)
self.score_label = score_label
vlay = QtWidgets.QVBoxLayout()
vlay.addWidget(upvote_btn)
vlay.addWidget(score_label)
vlay.addWidget(downvote_btn)
vlay.addStretch()
hlay = QtWidgets.QHBoxLayout(container)
hlay.addLayout(vlay)
hlay.addWidget(rant_content)
QSS:
QWidget#rant-container{
background-color: white;
}
QWidget#rant-container:hover{
background-color: #f2f2f2;
}
QWidget#rant-content{
min-height: 180px;
min-width: 660px;
max-width: 660px;
}