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. automatic Size policy when resizing window

automatic Size policy when resizing window

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 1.2k 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.
  • S Offline
    S Offline
    SimonChoops
    wrote on last edited by
    #1

    hello,
    I'm searching from this morning how to do that ... I tried lot of things but never works.
    I would like to automaticaly resize policy when resizing window
    other thing, I tried to but the background in black ... but tried some tuto without success...
    If somebody can help me please:

    QWidget *widgetFondNoir = new QWidget();
    

    // widgetFondNoir->setStyleSheet("background-color: black");
    auto palette = widgetFondNoir->palette();
    palette.setColor(QPalette::Window, Qt::blue);
    widgetFondNoir->setPalette(palette);

    //Variables
    test=0;
    qTimeHeure.setHMS(0,0,00,000);
    qTimeHeureMeeting.setHMS(0,0,00,000);
    qTimeHeureRestante.setHMS(0,45,00,000);
    
    QLabel *labelHeure = new QLabel(this);
    QLabel *labelHeureRestant1 = new QLabel(this);
    QLabel *labelHeureRestant2 = new QLabel(this);
    QLabel *labelHeureRestant3 = new QLabel(this);
    
    labelHeure->setText(" HEURE : 19:25:54 ");
    labelHeure->setAlignment(Qt::AlignCenter);
    //labelHeure->setFont(QFont("Comic Sans MS", 14));
    
    labelHeureRestant1->setText(" TRACK WALK : 19:25:54 ");
    labelHeureRestant1->setAlignment(Qt::AlignCenter);
    //labelHeureRestant1->setFont(QFont("Comic Sans MS", 14));
    
    labelHeureRestant2->setText(" Mechanical_Fire_Up : 19:25:54 ");
    labelHeureRestant2->setAlignment(Qt::AlignCenter);
    //labelHeureRestant2->setFont(QFont("Comic Sans MS", 14));
    
    labelHeureRestant3->setText(" Test_Session_4 : 19:25:54 ");
    labelHeureRestant3->setAlignment(Qt::AlignCenter);
    //labelHeureRestant3->setFont(QFont("Comic Sans MS", 14));
    
    //Layout
    QGridLayout *layoutPrincipal = new QGridLayout(widgetFondNoir);
    QGridLayout *layoutMilieu = new QGridLayout(widgetFondNoir);
    
    layoutPrincipal->addWidget(boutonQuitter,12,10,1,3);
    layoutPrincipal->addWidget(boutonConnect,12,2,1,3);
    layoutMilieu->addWidget(labelHeure,1,3,2,4);
    layoutMilieu->addWidget(labelHeureRestant1,3,2,2,7);
    layoutMilieu->addWidget(labelHeureRestant2,6,2,2,7);
    layoutMilieu->addWidget(labelHeureRestant3,9,2,2,7);
    layoutPrincipal->addLayout(layoutMilieu,0,6);
    this->setLayout(layoutPrincipal);
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SimonChoops said in automatic Size policy when resizing window:

      QGridLayout *layoutPrincipal = new QGridLayout(widgetFondNoir);
      QGridLayout *layoutMilieu = new QGridLayout(widgetFondNoir);

      Why do you create two layouts for the same widget?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      S 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @SimonChoops said in automatic Size policy when resizing window:

        QGridLayout *layoutPrincipal = new QGridLayout(widgetFondNoir);
        QGridLayout *layoutMilieu = new QGridLayout(widgetFondNoir);

        Why do you create two layouts for the same widget?

        S Offline
        S Offline
        SimonChoops
        wrote on last edited by
        #3

        @Christian-Ehrlicher
        Hello,

        This is to have a layout inside another one, because with just one when I resize it makes strange things.
        maybe it is not the go way to do but for the moment doesn't matter ^^ I would like the policy resized in the same time the window is resized...
        you now how to ?

        Thank you

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

          Hi,

          Passing a parent to a layout will apply that layout on the parent so if you want to have a layout in another layout, don't give a partent to that second layout and use the addLayout method of the main one.

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

          S 1 Reply Last reply
          3
          • SGaistS SGaist

            Hi,

            Passing a parent to a layout will apply that layout on the parent so if you want to have a layout in another layout, don't give a partent to that second layout and use the addLayout method of the main one.

            S Offline
            S Offline
            SimonChoops
            wrote on last edited by
            #5

            @SGaist
            Hello,

            Ok I will do that but an idea for the main subject ? resize text in function of window's size ?

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @SimonChoops said in automatic Size policy when resizing window:

              resize text in function of window's size ?

              Where did you ask this question?
              You ant to automatically resize the text when the widget gets resized? You have to implement this by your own by e.g. overriding QWidget::resizeEvent()

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              S 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @SimonChoops said in automatic Size policy when resizing window:

                resize text in function of window's size ?

                Where did you ask this question?
                You ant to automatically resize the text when the widget gets resized? You have to implement this by your own by e.g. overriding QWidget::resizeEvent()

                S Offline
                S Offline
                SimonChoops
                wrote on last edited by
                #7

                @Christian-Ehrlicher
                Hello,
                on my first message :) and this is the name of the topic as well.

                I have to implement it really ? it's strange that is not possible basically.

                I don't have the level in QT to do this...

                anyway
                Thank you for your answer

                Simon

                JonBJ 1 Reply Last reply
                0
                • S SimonChoops

                  @Christian-Ehrlicher
                  Hello,
                  on my first message :) and this is the name of the topic as well.

                  I have to implement it really ? it's strange that is not possible basically.

                  I don't have the level in QT to do this...

                  anyway
                  Thank you for your answer

                  Simon

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #8

                  @SimonChoops
                  You seemed to ask several different questions, it's not clear (to me, maybe others) just what it is you want.

                  What resizing did you want/expect? When did "resize text" come into what you were asking? Resize in what way? I see you have lines commented out which had setFont() and a text size number, is that what you want/expect to change? So the font changes size when other things resize??

                  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