本文整理汇总了C++中QScreen::availableSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QScreen::availableSize方法的具体用法?C++ QScreen::availableSize怎么用?C++ QScreen::availableSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScreen
的用法示例。
在下文中一共展示了QScreen::availableSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QQmlApplicationEngine engine;
QQmlContext* context = engine.rootContext();
QString currPath = QDir::currentPath();
context->setContextProperty("currentPath", currPath);
QScreen *screen = QApplication::screens().at(0);
int width = screen->availableSize().width();
context->setContextProperty("availableWidth", width);
int height = screen->availableSize().height();
context->setContextProperty("availableHeight", height);
MainController* mainController = new MainController();
context->setContextProperty("mainController", mainController);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
示例2: QDialog
LoginDialog::LoginDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::LoginDialog)
{
ui->setupUi(this);
QScreen *screen = QApplication::screens().at(0);
//int screenWidth = screen->availableSize().width();
int screenHeight = screen->availableSize().height();
QFont defaultHeight;
defaultHeight.setPointSize(18);
int ButtonHeight = screenHeight / 20;
ui->label_User->setText("Benutzername:");
ui->label_User->setFont(defaultHeight);
ui->label_password->setText("Passwort:");
ui->label_password->setFont(defaultHeight);
ui->label_IP_login->setText("Server Url/IP:");
ui->label_IP_login->setFont(defaultHeight);
ui->pushButton_OK->setText("OK");
ui->pushButton_OK->setMaximumHeight(ButtonHeight);
ui->pushButton_cancel->setText("Abbrechen");
ui->pushButton_cancel->setMaximumHeight(ButtonHeight);
ui->lineEdit_password->setEchoMode(QLineEdit::Password);
ui->label_headline->setAlignment(Qt::AlignCenter);
QFont font = ui->label_headline->font(); //Set layout of label
font.setBold(true);
font.setPointSize(screenHeight / 60);
ui->label_headline->setFont(font);
ui->label_headline->setText("HWWS Login");
QString IP = settingsIP.value("Url", "").toString();
ui->lineEdit_IP_login->setText(IP);
QString User = settingsUser.value("name", "").toString();
ui->lineEdit_user->setText(User);
QString Password = settingsUser.value("password", "").toString();
ui->lineEdit_password->setText(Password);
}