How to setBottomWidget insteads of setCentralWidget? and color? (solved)
-
How to set it to scroll at the bottom of the dialog box
-
i need the code urgently, please help.
-
At the bottom of a QDialog ? You can use a QVBoxLayout
-
how to create multiple instances of this ticker
-
The same way you create multiple instances of any other classes in C++
-
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);
-
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);
-
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 -
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 -
[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.
-
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 layoutTicker* 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);
-
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?
-
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
-
--How to remove former layout---
under ui->setupUi(this);
I inserted: delete layout();before adding your code. No progress.
-
Again: stop trying to put your own layout in QMainWindow, it's not meant for that.
-
deleted mainwindow source file.
Insert above code into main instead.
compiler complain setCentralWidget was not declared in this scope. -
Sure it's not, it's meant to be used in a QMainWindow subclass constructor