Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QSS File Changing MainWindow size from Maximised
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QSS File Changing MainWindow size from Maximised

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ion_knight
    wrote on last edited by
    #1

    Quick question I have a QSS file that i use to set the style and this works great. However I seem to be getting a weird problem.

    When I launch the program I tell it to start in fullscreen but instead the program launches as a small window with

    @

    GUIForm lGUIForm(aFullscreen, fOwner,aConfiguration);
    
    if (aFullscreen)
    {
        lGUIForm.showMaximized();
    }
    else
    {
        lGUIForm.show();
    }
    

    if (!loadQTStylesheet())
    {
    LOG_WARN << "Stylesheet load failed. Using default display";
    }
    return fApplication.exec()
    @

    Below is my stylesheet

    @QDialog
    {
    background-color: #3A3A53;
    font-family: "DejaVu Sans";
    }

    #MAINFRM
    {
    background-color: #3A3A53;
    font-family: "DejaVu Sans";
    }

    #HEADER
    {
    background-color: rgb(12, 12, 40);
    color: rgb(255, 255, 255);
    font-family: "DejaVu Sans";
    }

    #MENUBAR
    {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #ffffff, stop: 1 #c2c2d4);
    }

    #FILTERBAR
    {
    background-color: rgb(58, 58, 83);
    }

    #VIDEOFRM
    {
    background-color: rgb(0, 0, 0);
    }

    #ALARMBAR
    {
    background-color: rgb(35, 35, 61);
    color: rgb(255, 255, 255);
    }

    #MSGBOX
    {
    background-color: #141428;
    font-family: "DejaVu Sans";
    color: #D9D9EA;
    border: 0px solid #9595A9;
    padding: 0 10px 0 10px;
    }

    #IndicationPanel
    {
    font-family: "DejaVu Sans" ;
    background-color: #3C3C79 ;
    border-color: #67677E ;
    color: #67677E ;
    border-style: solid ;
    border-width: 2px ;
    border-radius: 4px ;
    }

    QLabel
    {
    background-color: #3A3A53;
    font-family: "DejaVu Sans";
    color: #D9D9EA;
    }

    QPushButton:hover:pressed{
    font-family: "DejaVu Sans";
    background-color: #3F3FB3 ;
    border-color: #F0F0FF ;
    color: #F0F0FF ;
    border-style: solid;
    border-width: 2px;
    border-radius: 4px;
    }
    QPushButton:hover:!pressed {
    font-family: "DejaVu Sans";
    background-color: #D9D9EA ;
    border-color: #000000 ;
    color: #3A3A53 ;
    border-style: solid;
    border-width: 2px;
    border-radius: 4px;
    }
    QPushButton:!hover {
    font-family: "DejaVu Sans";
    background-color: #D9D9EA ;
    border-color: #000000 ;
    color: #3A3A3A ;
    border-style: solid;
    border-width: 2px;
    border-radius: 4px;
    }
    QPushButton:disabled{
    background-color: #9595A9;
    border-color: #67677E;
    color: #67677E;
    font-family: "DejaVu Sans";
    border-style: solid;
    }
    QPushButton:disabled:pressed{
    background-color: #3C3C79;
    border-color: #67677E;
    color: #67677E;
    font-family: "DejaVu Sans";
    border-style: solid;
    }@

    The weird thing is I know it's to do with the stylesheet as if i stop it from being loaded the program launches in fullscreen. Has anyone seen this or have any solution how to solve this that would be great.

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ion_knight
      wrote on last edited by
      #2

      Well I have nailed down the problem to 3 lines in the stylesheet if i put either in the code the window will always open to the smaller size (but you can see the window first tries to go full screen then is quickly changed).

      The 3 problem lines are as follows:
      font-family: "DejaVu Sans";
      font: bold 14px;

      border-style: solid;

      If anyone has a solution to this that would be great as quite frankly losing my mind, can anything in my code effect the QSS file?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Something's not clear, since you want to show your dialog in full screen, why not call showFullScreen ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • I Offline
          I Offline
          ion_knight
          wrote on last edited by
          #4

          Sorry SGaist,
          Meant to say Maximised, what's happening is it tries to go maximised(as that is first in the code), then it loads the stylesheet. When it loads the Qt stylesheet it shrinks it, if i remove the loading of the stylesheet, i obviously have no style to anything but the window is maximised. Any ideas what I could be doing wrong? I don't understand why removing fonts and border-style from my stylesheet will allow it to work.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ion_knight
            wrote on last edited by
            #5

            Fixed the problem it's related to order of the code. Specifically show maximised must be run before loading the qt stylesheet, otherwise strange problems with the style sheet will occur. Once I changed the code to load the stylesheet first the code began working again.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved