#๐ need help with fixing my dropdown menu
95 messages ยท Page 1 of 1 (latest)
@quick tapir
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
could you paste the entire code file and send the link please?
and also you mention a qss file, im not sure what i should name that
let me explain qss is like css but for pyside6
hold on im getting all the info together so i can explain it fully
The highlight is precisely 125 pixels wide
its 167 on my screen
ok im sending over some more images too.
Okay, fine, the button and menu are 320 raw px (160 non-retina), the highlight is 250 (125 non retina)
i will send code for this and code for the first image i was able to isolate the issue somehow and get the bar to fully expand
can i just take a moment to let you all know that i love you very much
this looks like overlapped elements
thats what im trying to figure out too im trying to send the code but its too long so i need to split it
missing border radius on the selected block if it's the first item?
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Weird behavior though, css doesn't do that in browsers
oh snap soo helpful i love you
this is a desktop application
ok heres first code https://paste.pythondiscord.com/Z3VQ
this code is the green dropdown i have more to send one second
this is the style for the dropdown
ok i can see it on my end now
this is the qss style for the button im trying to fix https://paste.pythondiscord.com/X5RA
there you go i sent over the python for each dropdown menu then the qss stylesheet for both menus. now my issue is i cant seem to get the bar to fully stretch
also i just want to express how appreciative i am for people stopping what there doing to help me out you have no idea how much that means to me
your issue is the width: 100%. if i set it to width: 160px it looks fine
so i think its because the container isnt automatically growing either
the background not having border-radius applied is another issue...
so thats all i need to do then set it to 160?
i think the layout (QVBoxLayout) is missing style
hold on let me see if this works
this makes me wish there was some kind of "inspect element" tool for this
sending the code for just the sidebar area one second
hm so i get this now
what is the structure of the elements here?
QWidget -> QVBoxLayout -> QMenu / QPushButton?
this is entire sidebar
https://paste.pythondiscord.com/3EIQ this is the qss stylesheet for said sidebar
heres the structure of the elements in the sidebar section
QWidget (sidebar)
QVBoxLayout (sidebar_layout)
QWidget (sidebar_top_bar)
QHBoxLayout (sidebar_top_bar_layout)
QLabel (sidebar_label)
QSpacerItem (8px spacer)
QHBoxLayout (button_layout)
QPushButton (sidebar_button_1)
QSpacerItem (4px spacer)
QHBoxLayout (button_layout_2)
QPushButton (sidebar_button_2)
QSpacerItem (4px spacer)
QHBoxLayout (button_layout_3)
QPushButton (sidebar_dropdown_button)
QMenu (dropdown_menu)
QAction (for each frequency)
QSpacerItem (stretch)
https://doc.qt.io/qt-6/stylesheet-reference.html#width this might be important
Warning: Unless otherwise specified, this property has no effect when set on widgets. If you want a widget with a fixed width, set the min-width and max-width to the same value.
i will look at that
what are you doing im over here pulling my hair out
one second let me figure out how to fix the button width
okay i really really appreciate you
look about right?
here is the qss
QPushButton {
padding: 6px 12px;
min-width: 160px; /* Set min and max width to desired size */
max-width: 160px;
}
QMenu {
background-color: #333333;
border: 1px solid #555555;
color: white;
font-family: "Segoe UI";
font-size: 10pt;
border-radius: 4px;
margin: 0; /* Remove any margin around the menu */
padding: 0; /* Ensure no internal padding in the menu */
}
QMenu::item {
padding: 6px 12px; /* Ensuring consistent padding */
border-radius: 4px;
background-color: transparent;
font-weight: normal;
min-width: 160px; /* Set min and max width to match button */
max-width: 160px;
}
QMenu::item:selected {
background-color: #5A9CF0;
color: #ffffff;
}
i also removed the setFixedSize and setFixedWidth calls from the python code
basically the solution is min and max width
wow let me see
since width itself seems to do nothing
i understand what you mean
i just don't understand what's going on. it didn't fix it
it looks better rounded though
not blaiming you im just llike wtf in general
im guessing that using setFixedWidth will override the width for that widget, but it wont affect any child elements width that depend on it
humm
looks like setting the width on the QMenu and using 100% on the items doesnt work either
so set min-width and max-width to 160px on the items themselves
nope but i sent over some testing code earlier that has the thing working for some reason
let me catch up. can you send your current code and qss?
that produces this result
this is the test code that's green i can send my code right now hold on
that's the sidebar app.py
its missing imports and things. can you send the entire file as a paste?
yep one moment
sorry got tied up
https://paste.pythondiscord.com/KVOQ this is the full app window and sidebar
that is the qss stylesheet
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.