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. Tickers cannot run into QGridLayout, no moving text can be seen (solved)
Forum Updated to NodeBB v4.3 + New Features

Tickers cannot run into QGridLayout, no moving text can be seen (solved)

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 1.6k 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
    #1

    The Marquee Text could run when below code is used individually
    @
    QMainWindow::setCentralWidget(pTicker);
    @
    Tickers cannot run in QGridLayout, no moving text can be seen, Please help.
    @
    layout->addWidget(pTicker,2,0,1,2);
    @

    @

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QPushButton>
    #include <QGridLayout>
    #include <QLabel>
    #include "ticker.h"
    #include <QMainWindow>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    QWidget *window= new QWidget;
    window->setWindowTitle("My App");

    QLabel *label= new QLabel("Hello");
    Ticker* pTicker = new Ticker(this);
    pTicker->setText("hello this is a long text");
    
    QGridLayout *layout= new QGridLayout;
    video();
    
    layout->addWidget(videoWidget,0,0);
    layout->addWidget(videoWidget1,0,1);
    layout->addWidget(label,1,0,1,2);
    layout->addWidget(pTicker,2,0,1,2);                             //doesn't appear when run
    //QMainWindow::setCentralWidget(pTicker);
    
    
    video();
    window->setLayout(layout);
    window->show();
    

    }

    void MainWindow::video()
    {
    playlist= new QMediaPlaylist();
    player= new QMediaPlayer;
    videoWidget = new QVideoWidget;
    playlist->addMedia(QUrl::fromLocalFile("/opt/hotgirl.mp4"));
    player->setPlaylist(playlist);

    playlist1= new QMediaPlaylist();
    player1= new QMediaPlayer;
    videoWidget1 = new QVideoWidget;
    playlist1->addMedia(QUrl::fromLocalFile&#40;"/opt/hotgirl.mp4"&#41;&#41;;
    player1->setPlaylist(playlist&#41;;
    
    
    player->setVideoOutput(videoWidget);
    player1->setVideoOutput(videoWidget1);
    //videoWidget->show();
    playlist->setCurrentIndex(1);
    playlist1->setCurrentIndex(1);
    player->play();
    player1->play();
    

    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    @

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      Whats the type of Ticker class? Can you guarantee that the widget works as expected?

      Also don't set a layout on the QMainWindow.
      Rather set it on a new widget and set this widget as the central widget.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • H Offline
        H Offline
        houmingc
        wrote on last edited by
        #3

        it is proven working

        i got it from link below

        http://thisthread.blogspot.sg/2010/07/ticker-timer-event.html

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          [quote author="raven-worx" date="1422612257"]
          Also don't set a layout on the QMainWindow.
          Rather set it on a new widget and set this widget as the central widget.[/quote]
          did you try it?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rondog
            wrote on last edited by
            #5

            The problem is either the 'Ticker' widget or how you are using this widget in your program. There is no way it has anything to do with the QGridLayout.

            If you substitute this widget with something else (i.e. QLabel with some text set) you should be able to see it in the proper location. At least this would verify your programs use of the QGridLayout.

            I followed the link. I didn't see the download but I did notice references to Qt4 in the description (nothing to Qt5). Maybe something needs to be changed in this widget in order to work with the new version of Qt? (which I assume you are using). Just a thought.

            1 Reply Last reply
            0
            • H Offline
              H Offline
              houmingc
              wrote on last edited by
              #6

              The ticker widget used a timerEvent 30 second to call paintEvent repainting saved QString text creating the text shift.

              It is using setCentralWidget setting the moving text in MainWindow central. I tested it working and want to use it at the bottom of MainWindow. It inherit QWidget, i thought i could use it in QGridLayout??

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

                Hi,

                You can't change the layout of a QMainWindow. However if by bottom you mean the status bar, then you can set widgets on it.

                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