I currently use the following style-sheet property for a dynamically created QPushButton
string mystyle = "QPushButton { border: 1px solid #8f8f91; border-radius: 1px; min-width: 90px; min-height: 18px;}"
The QPushButton also has an icon next to it - The QPushbutton is inside a QToolBar
This style works fine when the app runs on my computer.However the problem starts when the application is run on another system in which the Display is magnified. (On windows-7 this is done by going to display in control panel and selecting Larger-150%). When the app is ran on a system with magnified display this is what I get. (The text in it is suppose to be "Hello MyBig World!!") Notice the exclamation marks are missing
I believe this problem only occurs when there is an icon in the button. Without the icon the QpushButton Looks fine. This is how it looks like without the icon. Notice the text is now completely visible.
This is how I am creating my QPushButton
QPushButton *button_test = new QPushButton( "Hello MyBig World!!" ,this);
button_test->setStyleSheet(mystyle.c_str());
button_test->setIcon(QIcon(":/../SomeFile.png"));
Any suggestion on why this is happening and how I can resolve this issue - The button width is fine on my computer with all the text appearing along with the exclamation marks. However all the text does not appear on the computer whose font is magnified. Inorder to display the entire text on that computer I need to restyle the style sheet changing and increasing the min-width.I do not want to restyle all the time and wanted to know the proper and an efficient solution to this problem.
Update
This is the code that I am using now
std::string pbstyles = "QPushButton { border: 1px solid #8f8f91; border-radius: 1px; font: 12px;"
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde); "
"padding-right:50px;padding-left:50px;height:25px; }"
"QPushButton:pressed { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa); }"
"QPushButton:hover{background-color: qlineargradient(spread:pad, x1:0, y1:0.0568182, x2:1, y2:0.0454545, stop:0 rgba(85, 170, 255, 255), stop:1 rgba(255, 255, 255, 255));}";
std::string ArrowStyle = "QPushButton::menu-indicator {/*background-color: darkblue ;*/ subcontrol-origin: padding; margin-right: -60px}";
pbstyles+=ArrowStyle;
QMenu *menu = new QMenu("This is a button",this);
QPushButton *button = new QPushButton( menu->title(),this);
button->setMenu(menu_contacts);
button->setStyleSheet(pbstyles.c_str());
button->setIcon(QIcon(":/someicon.ico"));
button->setIconSize(QSize(16, 16));
ui.toolBar->addWidget(button_contacts);
and this is what I get (notice the text is still chopped :( !!!!)
On my tests this is happening because the icon and the text of the button are magnified, but the button not, to solve this issue you can use this:
And:
These settings should guarantee that both icon and text of the button will have the same size on magnified and not magnified desktops.