Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to setBottomWidget insteads of setCentralWidget? and color? (solved)
Forum Updated to NodeBB v4.3 + New Features

How to setBottomWidget insteads of setCentralWidget? and color? (solved)

Scheduled Pinned Locked Moved Mobile and Embedded
26 Posts 3 Posters 7.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.
  • H Offline
    H Offline
    houmingc
    wrote on last edited by
    #21

    Is there other container that i can use other than QVBoxLayout.
    what does showEvent and hideEvent do exactly in ticker.cpp?

    can give more guidance for this problem?

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

      To work with QMainWindow's central widget you have to create a container widget and work on it. I already wrote that setting a layout on a QMainWindow will fail since it already has one.

      @
      QWidget *containerWidget = new QWidget;
      QVBoxLayout *layout = new QVBoxLayout(containerWidget);
      layout->addStretch(1);
      layout->addWidget(pTicker);
      setCentralWidget(containerWidget);
      @

      "QMainWindow":http://qt-project.org/doc/qt-5/qmainwindow.html#qt-main-window-framework

      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
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #23

        --How to remove former layout---

        under ui->setupUi(this);
        I inserted: delete layout();

        before adding your code. No progress.

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

          Again: stop trying to put your own layout in QMainWindow, it's not meant for that.

          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
          • H Offline
            H Offline
            houmingc
            wrote on last edited by
            #25

            deleted mainwindow source file.
            Insert above code into main instead.
            compiler complain setCentralWidget was not declared in this scope.

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

              Sure it's not, it's meant to be used in a QMainWindow subclass constructor

              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

              • Login

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