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

How setStylesheet ocuppy resolution 1366 by 254 only



  • My picture resolution is 1366 by 254.
    Would like setStyleSheet to occupy 1366 by 254 and mainwindow size is 1366 by 1016.

    MainWindow w;
    w.setStyleSheet("background-image:url(:/file/left.png)");
    w.setFixedSize(1366,1016);
    //254 x 4

  • Moderators

    I'm not sure I understand you correctly but do you mean you don't want the image to repeat? If so then set the repeat mode:

    w.setStyleSheet("background-image:url(:/file/left.png); background-repeat: no-repeat");


  • Chris thanks

    want setStyleSheet to occupy top quarter of the mainWindow.
    MainWindow size is 1366 by 1016


  • Moderators

    So... have you tried my suggestion? It should do what you want.



  • yes i have,
    w.setStyleSheet("background-image:url(:/file/left.png); background-repeat: no-repeat");

    It only fills up PC monitor width, thus i add setFixedWidth to set the width i want
    w.setFixedWidth(1366);

    On my laptop it work perfectly, but when i cross-compile and test it on the ARM target.
    The mainwindow is expanded over the whole screen. Is there any workaround?


Log in to reply