跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  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)

已排程 已置頂 已鎖定 已移動 Mobile and Embedded
26 貼文 3 Posters 7.7k 瀏覽 1 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • H 離線
    H 離線
    houmingc
    寫於 最後由 編輯
    #1

    I created a banner based on the sample code below
    http://thisthread.blogspot.sg/2010/07/ticker-timer-event.html

    Currently, i am using QMainWindow::setCentralWidget
    How to create banner at the bottom of my MainWindow?
    Also how to set the widget to red color?

    1 條回覆 最後回覆
    0
    • H 離線
      H 離線
      houmingc
      寫於 最後由 編輯
      #2

      Is it possible to write the text on a text label?
      ui->txtlabel->pTicker

      currently my code is below

      pTicker->setText(" hello ");

      1 條回覆 最後回覆
      0
      • IamSumitI 離線
        IamSumitI 離線
        IamSumit
        寫於 最後由 編輯
        #3

        Hi..

        How to create banner at the bottom of my MainWindow?
        you can set your banner on Status Bar of QMainWindow.
        or even you can take QWidget and set using setgeometry() function/method of that Widget.
        how to set the widget to red color?
        "find here":http://qt-project.org/wiki/How_to_Change_the_Background_Color_of_QWidget
        Is it possible to write the text on a text label?
        yes it is possible.

        hope this helps.

        Be Cute

        1 條回覆 最後回覆
        0
        • H 離線
          H 離線
          houmingc
          寫於 最後由 編輯
          #4

          can you write out the code that enable text on Qlabel

          1 條回覆 最後回覆
          0
          • SGaistS 離線
            SGaistS 離線
            SGaist
            Lifetime Qt Champion
            寫於 最後由 編輯
            #5

            Do you mean "setText":http://qt-project.org/doc/qt-5/qlabel.html#text-prop ?

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

            1 條回覆 最後回覆
            0
            • H 離線
              H 離線
              houmingc
              寫於 最後由 編輯
              #6

              i need a scrolling text.
              I achieve by pTicker->setText(” hello “);

              How to put pTicker onto a textlabel?

              1 條回覆 最後回覆
              0
              • SGaistS 離線
                SGaistS 離線
                SGaist
                Lifetime Qt Champion
                寫於 最後由 編輯
                #7

                Ok, you don't need a QLabel, just put your pTicker directly at the right place

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

                1 條回覆 最後回覆
                0
                • H 離線
                  H 離線
                  houmingc
                  寫於 最後由 編輯
                  #8

                  How to put pTicker at the right place?
                  i putting it using QMainWindow::setcentralWidget(pTicker);

                  I tried QToolbar *fontToolBar= new QToolBar(tr("Font");
                  fontToolBar->setObjectName("FontToolBar");
                  fontToolBar->addWidget(pTicker);
                  not successful.

                  I tried QLabel *bannerLabel=new QLabel(pTicker);
                  bannerLabel->setAlignment(Qt::AlignVCenter);
                  It works, but no matter setting AlignHCenter or AlignBaseline or other alignment, it is fixes to the top left.

                  Thanks for the good deeds, promise to pass it around.

                  1 條回覆 最後回覆
                  0
                  • SGaistS 離線
                    SGaistS 離線
                    SGaist
                    Lifetime Qt Champion
                    寫於 最後由 編輯
                    #9

                    [quote author="houmingc" date="1414852099"]
                    I tried
                    @QToolbar *fontToolBar= new QToolBar(tr("Font");
                    fontToolBar->setObjectName("FontToolBar");
                    fontToolBar->addWidget(pTicker);
                    @
                    not successful.
                    [/quote]
                    What do you mean by not successful ?

                    [quote author="houmingc" date="1414852099"]
                    I tried
                    @
                    QLabel *bannerLabel=new QLabel(pTicker);
                    bannerLabel->setAlignment(Qt::AlignVCenter);
                    @
                    It works, but no matter setting AlignHCenter or AlignBaseline or other alignment, it is fixes to the top left.
                    [/quote]

                    That's normal, you are telling QLabel to align it's content that way. However bannerLabel doesn't have any content. You just made it a child of pTicker.

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

                    1 條回覆 最後回覆
                    0
                    • H 離線
                      H 離線
                      houmingc
                      寫於 最後由 編輯
                      #10

                      How to set it to scroll at the bottom of the dialog box

                      1 條回覆 最後回覆
                      0
                      • H 離線
                        H 離線
                        houmingc
                        寫於 最後由 編輯
                        #11

                        i need the code urgently, please help.

                        1 條回覆 最後回覆
                        0
                        • SGaistS 離線
                          SGaistS 離線
                          SGaist
                          Lifetime Qt Champion
                          寫於 最後由 編輯
                          #12

                          At the bottom of a QDialog ? You can use a QVBoxLayout

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

                          1 條回覆 最後回覆
                          0
                          • H 離線
                            H 離線
                            houmingc
                            寫於 最後由 編輯
                            #13

                            how to create multiple instances of this ticker

                            1 條回覆 最後回覆
                            0
                            • SGaistS 離線
                              SGaistS 離線
                              SGaist
                              Lifetime Qt Champion
                              寫於 最後由 編輯
                              #14

                              The same way you create multiple instances of any other classes in C++

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

                              1 條回覆 最後回覆
                              0
                              • H 離線
                                H 離線
                                houmingc
                                寫於 最後由 編輯
                                #15

                                My objective is to get a scrolling text below the Main Window dialog box. Below is my code, implementing QVBoxLayout, nothing is change, please give some more advice. Thanks

                                Ticker* pTicker = new Ticker(this);
                                pTicker->setText("  I love u but u love me not     ");
                                QMainWindow::setCentralWidget(pTicker);
                                QVBoxLayout *vbox=new QVBoxLayout(this);
                                vbox->addWidget(pTicker);
                                
                                QPalette pal=palette();
                                pal.setColor(QPalette::Background,Qt::green);
                                setPalette(pal);
                                setAutoFillBackground(true);
                                
                                1 條回覆 最後回覆
                                0
                                • H 離線
                                  H 離線
                                  houmingc
                                  寫於 最後由 編輯
                                  #16

                                  My objective is to get a scrolling text below the Main Window dialog box. Below is my code, implementing QVBoxLayout, nothing is change, please give some more advice. Thanks

                                  Ticker* pTicker = new Ticker(this);
                                  
                                  pTicker->setText("  I love u but u love me not     ");
                                  
                                  QMainWindow::setCentralWidget(pTicker);
                                  
                                  QVBoxLayout *vbox=new QVBoxLayout(this);
                                  
                                  vbox->addWidget(pTicker);
                                  
                                  QPalette pal=palette();
                                  
                                  pal.setColor(QPalette::Background,Qt::green);
                                  
                                  setPalette(pal);
                                  
                                  setAutoFillBackground(true);
                                  
                                  1 條回覆 最後回覆
                                  0
                                  • IamSumitI 離線
                                    IamSumitI 離線
                                    IamSumit
                                    寫於 最後由 編輯
                                    #17

                                    Hii.

                                    You can take some referance from the following link for scrolling the text.
                                    "here":http://stackoverflow.com/questions/12159443/qt-scrolling-the-text-in-qwidget

                                    Be Cute

                                    1 條回覆 最後回覆
                                    0
                                    • H 離線
                                      H 離線
                                      houmingc
                                      寫於 最後由 編輯
                                      #18

                                      I added cpp and header file to my added class.
                                      Compile successfully, created the object successfully
                                      When i build and run the program, other than the mainwindow, no text appear and scrolling.

                                      I went into below site. there is a zip file but i can't download, i have feedback to the administrator for months and there isn't any progress. Please help. Did i miss anything. it seems i am getting near to the answer.
                                      http://www.qtcentre.org/threads/24712-Marquee-QLabel

                                      1 條回覆 最後回覆
                                      0
                                      • SGaistS 離線
                                        SGaistS 離線
                                        SGaist
                                        Lifetime Qt Champion
                                        寫於 最後由 編輯
                                        #19

                                        [quote author="houmingc" date="1415239854"]My objective is to get a scrolling text below the Main Window dialog box. Below is my code, implementing QVBoxLayout, nothing is change, please give some more advice. Thanks
                                        @
                                        Ticker* pTicker = new Ticker(this);

                                        pTicker->setText("  I love u but u love me not     ");
                                        
                                        QMainWindow::setCentralWidget(pTicker);
                                        
                                        QVBoxLayout *vbox=new QVBoxLayout(this);
                                        
                                        vbox->addWidget(pTicker);
                                        
                                        QPalette pal=palette();
                                        
                                        pal.setColor(QPalette::Background,Qt::green);
                                        
                                        setPalette(pal);
                                        
                                        setAutoFillBackground(true);
                                        

                                        @
                                        [/quote]

                                        You are setting pTicker as central widget, then you are setting a QVBoxLayout on your MainWindow which will fail since QMainWindow already has a layout.

                                        So all in all, if you want your pTicker at the bottom in your QMainWindow centralWidget, then put in on the bottom of a widget that you will set as central widget.

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

                                        1 條回覆 最後回覆
                                        0
                                        • H 離線
                                          H 離線
                                          houmingc
                                          寫於 最後由 編輯
                                          #20

                                          Dear sir, i commented out setCentrealWidget, still not working.

                                          QLayout: Attempting to add QLayout "" to MainWindow "MainWindow", which already has a layout
                                          QWidget::setLayout: Attempting to set QLayout "" on MainWindow "MainWindow", which already has a layout

                                          Ticker* pTicker = new Ticker(this);
                                          pTicker->setText("  I love u but u love me not     ");
                                          QLineEdit *lineEdit =new QLineEdit;
                                          //QMainWindow::setCentralWidget(pTicker);
                                          QVBoxLayout *vbox=new QVBoxLayout(this);
                                          vbox->addWidget(lineEdit);
                                          vbox->addWidget(pTicker);
                                          setLayout(vbox);
                                          
                                          1 條回覆 最後回覆
                                          0

                                          • 登入

                                          • Login or register to search.
                                          • 第一個貼文
                                            最後的貼文
                                          0
                                          • 版面
                                          • 最新
                                          • 標籤
                                          • 熱門
                                          • 使用者
                                          • 群組
                                          • 搜尋
                                          • Get Qt Extensions
                                          • Unsolved