Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Cross platform macOS & Windows 10 - Shape completely different



  • Hello,

    I need help :)

    I am developing on a macOS Catalina Version 10.15.7, I have installed parallel and a Windows 10 to try my application on Windows.
    I use anaconda on both platform, the same version of anaconda and anaconda is delivered with Qt 5.9.7, with Python 3.8.5.
    I develop on macOS and then I try on Windows, I am new to Qt Designer.
    On macOS, I have created an empty MainWindows, I have put some QpushButtton, QLabel and QLineEdit just to try, then I have saved it to ui. And when I try to open it on Windows (Folder are shared) the shape is completely different, nothing is at the good place, the size of the windows is not the same (smaller) I have tried to add a setStyle and nothing change on Windows.
    The setStyle change some thing on mac but I am lost on Windows because I can’t understand why is it so different, I don’t know what to add on Windows to have the same (I don’t want to design it again and have two application)

    I know that it is a problem of configuration but I can figure out what to do.

    When I do previlualisation on Mac with Windows style, I have the good shape.

    Thank you for your help

    Autogenerated code for information and a print screen

    Capture d’écran 2021-02-14 à 18.11.40.png

    /********************************************************************************
    ** Form generated from reading UI file 'testr24674.ui'
    **
    ** Created by: Qt User Interface Compiler version 5.9.7
    **
    ** WARNING! All changes made in this file will be lost when recompiling UI file!
    ********************************************************************************/

    #ifndef TESTR24674_H
    #define TESTR24674_H

    #include <QtCore/QVariant>
    #include <QtWidgets/QAction>
    #include <QtWidgets/QApplication>
    #include <QtWidgets/QButtonGroup>
    #include <QtWidgets/QGroupBox>
    #include <QtWidgets/QHeaderView>
    #include <QtWidgets/QLabel>
    #include <QtWidgets/QLineEdit>
    #include <QtWidgets/QMainWindow>
    #include <QtWidgets/QMenu>
    #include <QtWidgets/QMenuBar>
    #include <QtWidgets/QPushButton>
    #include <QtWidgets/QStatusBar>
    #include <QtWidgets/QWidget>

    QT_BEGIN_NAMESPACE

    class Ui_MainWindow
    {
    public:
    QAction *actiontest;
    QWidget *centralwidget;
    QLabel *label_2;
    QGroupBox *groupBox;
    QPushButton *bouton;
    QLabel *label_3;
    QPushButton *bouton_2;
    QLineEdit *choix_devise_contrepartie_achat;
    QGroupBox *groupBox_2;
    QPushButton *bouton_3;
    QLabel *label_4;
    QLabel *label_5;
    QPushButton *bouton_4;
    QMenuBar *menubar;
    QMenu *menufichier;
    QStatusBar *statusbar;

    void setupUi(QMainWindow *MainWindow)
    {
        if (MainWindow->objectName().isEmpty())
            MainWindow->setObjectName(QStringLiteral("MainWindow"));
        MainWindow->resize(900, 450);
        actiontest = new QAction(MainWindow);
        actiontest->setObjectName(QStringLiteral("actiontest"));
        centralwidget = new QWidget(MainWindow);
        centralwidget->setObjectName(QStringLiteral("centralwidget"));
        label_2 = new QLabel(centralwidget);
        label_2->setObjectName(QStringLiteral("label_2"));
        label_2->setGeometry(QRect(70, 100, 431, 20));
        QFont font;
        font.setFamily(QStringLiteral("Arial"));
        font.setPointSize(9);
        font.setBold(true);
        font.setWeight(75);
        label_2->setFont(font);
        label_2->setAlignment(Qt::AlignCenter);
        groupBox = new QGroupBox(centralwidget);
        groupBox->setObjectName(QStringLiteral("groupBox"));
        groupBox->setGeometry(QRect(210, 130, 291, 80));
        bouton = new QPushButton(groupBox);
        bouton->setObjectName(QStringLiteral("bouton"));
        bouton->setGeometry(QRect(10, 20, 71, 32));
        QFont font1;
        font1.setFamily(QStringLiteral("Arial"));
        bouton->setFont(font1);
        label_3 = new QLabel(groupBox);
        label_3->setObjectName(QStringLiteral("label_3"));
        label_3->setGeometry(QRect(140, 50, 100, 16));
        QFont font2;
        font2.setFamily(QStringLiteral("Arial"));
        font2.setPointSize(10);
        label_3->setFont(font2);
        label_3->setFrameShape(QFrame::StyledPanel);
        bouton_2 = new QPushButton(groupBox);
        bouton_2->setObjectName(QStringLiteral("bouton_2"));
        bouton_2->setGeometry(QRect(10, 50, 71, 32));
        bouton_2->setFont(font1);
        choix_devise_contrepartie_achat = new QLineEdit(groupBox);
        choix_devise_contrepartie_achat->setObjectName(QStringLiteral("choix_devise_contrepartie_achat"));
        choix_devise_contrepartie_achat->setGeometry(QRect(140, 20, 101, 18));
        QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        sizePolicy.setHorizontalStretch(0);
        sizePolicy.setVerticalStretch(0);
        sizePolicy.setHeightForWidth(choix_devise_contrepartie_achat->sizePolicy().hasHeightForWidth());
        choix_devise_contrepartie_achat->setSizePolicy(sizePolicy);
        choix_devise_contrepartie_achat->setFont(font1);
        groupBox_2 = new QGroupBox(centralwidget);
        groupBox_2->setObjectName(QStringLiteral("groupBox_2"));
        groupBox_2->setGeometry(QRect(210, 210, 291, 80));
        bouton_3 = new QPushButton(groupBox_2);
        bouton_3->setObjectName(QStringLiteral("bouton_3"));
        bouton_3->setGeometry(QRect(10, 20, 71, 32));
        bouton_3->setFont(font1);
        label_4 = new QLabel(groupBox_2);
        label_4->setObjectName(QStringLiteral("label_4"));
        label_4->setGeometry(QRect(140, 30, 100, 16));
        label_4->setFont(font2);
        label_4->setFrameShape(QFrame::StyledPanel);
        label_5 = new QLabel(groupBox_2);
        label_5->setObjectName(QStringLiteral("label_5"));
        label_5->setGeometry(QRect(140, 50, 100, 16));
        label_5->setFont(font2);
        label_5->setFrameShape(QFrame::StyledPanel);
        bouton_4 = new QPushButton(groupBox_2);
        bouton_4->setObjectName(QStringLiteral("bouton_4"));
        bouton_4->setGeometry(QRect(10, 50, 71, 32));
        bouton_4->setFont(font1);
        MainWindow->setCentralWidget(centralwidget);
        menubar = new QMenuBar(MainWindow);
        menubar->setObjectName(QStringLiteral("menubar"));
        menubar->setGeometry(QRect(0, 0, 900, 22));
        menufichier = new QMenu(menubar);
        menufichier->setObjectName(QStringLiteral("menufichier"));
        MainWindow->setMenuBar(menubar);
        statusbar = new QStatusBar(MainWindow);
        statusbar->setObjectName(QStringLiteral("statusbar"));
        MainWindow->setStatusBar(statusbar);
    
        menubar->addAction(menufichier->menuAction());
        menufichier->addAction(actiontest);
    
        retranslateUi(MainWindow);
    
        QMetaObject::connectSlotsByName(MainWindow);
    } // setupUi
    
    void retranslateUi(QMainWindow *MainWindow)
    {
        MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", Q_NULLPTR));
        actiontest->setText(QApplication::translate("MainWindow", "test", Q_NULLPTR));
        label_2->setText(QApplication::translate("MainWindow", "titre", Q_NULLPTR));
        groupBox->setTitle(QApplication::translate("MainWindow", "GroupBox", Q_NULLPTR));
        bouton->setText(QApplication::translate("MainWindow", "test", Q_NULLPTR));
        label_3->setText(QString());
        bouton_2->setText(QApplication::translate("MainWindow", "test", Q_NULLPTR));
    

    #ifndef QT_NO_STATUSTIP
    choix_devise_contrepartie_achat->setStatusTip(QApplication::translate("MainWindow", "Devise contrepartie", Q_NULLPTR));
    #endif // QT_NO_STATUSTIP
    groupBox_2->setTitle(QApplication::translate("MainWindow", "GroupBox", Q_NULLPTR));
    bouton_3->setText(QApplication::translate("MainWindow", "test", Q_NULLPTR));
    label_4->setText(QString());
    label_5->setText(QString());
    bouton_4->setText(QApplication::translate("MainWindow", "test", Q_NULLPTR));
    menufichier->setTitle(QApplication::translate("MainWindow", "fichier", Q_NULLPTR));
    } // retranslateUi

    };

    namespace Ui {
    class MainWindow: public Ui_MainWindow {};
    } // namespace Ui

    QT_END_NAMESPACE

    #endif // TESTR24674_H


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    One thing that is missing is: layouts. You do not have any which makes your UI pretty rigid.

    One thing to take into account when just sharing is that the .pro.user file created by Qt Creator is machine specific so you may have issues building because of that. You should rather use git and sync each clone rather than reusing the same folder.

    Unrelated note, please use coding tags when posting code, that will make it readable.



  • @SGaist said in Cross platform macOS & Windows 10 - Shape completely different:

    One thing that is missing is: layouts. You do not have any which makes your UI pretty rigid.

    Hello,

    First thank you for taking time to answer.
    I will read more about layout but I don't think it will solve my problem, just the size of the Windows is divided by 5 without adding anything.
    For the clone, I have tried with the shared .ui file and also with the conversion pyuic5 -x from ui to py.
    The execution of the .py on spyder is good on macOS but the result on Windows spyder is still ugly :(
    I will use git but I also don't think it will solve my problem.

    At least the variable are the same so if I don't find a way, I will redesign the Gui on Windows to have same as macOS and copy/past the new code I am adding with spyder from macOS to Windows. Old school style.



  • @FFF1 said in Cross platform macOS & Windows 10 - Shape completely different:

    I don't think it will solve my problem

    It will solve your GUI problem.

    It also seems that you are comparing the look of the GUI at runtime (macOs) with the Qt Designer preview GUI on Windows. The preview in Qt Designer looks a bit different in most cases (when using layouts, it will look more similar)


Log in to reply