Flickable in qt
-
Hi all,
I have a Gui screen which is working fine. But I am out of space in the screen, hence I have to add the scroll feature in this screen. Since it is a touchscreen hence i want to use a flickable scroll bar in it.
Can you please help me to understand how to start for this, I had gone through qt examples but they all deal with List widget....which is not in my case. I don't want to disturb the Gui of my screen I just want to add the flickable scrolling feature in it.
Is that possible? If yes, then how it can be done.Thanks in advance,
Pragati -
If you are not on QML (whose lists are flickable by default) the "flick charm":http://labs.qt.nokia.com/2008/11/15/flick-list-or-kinetic-scrolling/ might be of interest for you, which supports all C++ classes inheriting QAbstractScrollArea (there is a "solution":http://labs.qt.nokia.com/2009/07/19/kinetic-scrolling-on-any-widgets/ for classes not inheriting it as well, which is slightly more complicated).
-
Yeah I am not on QML......So its complicated than a simple scrollbar...or equivalent.....;)
I have to use scroll feature anyhow but flickable will be better so thought to give it a try....I don't know from where and how to start....Thanks for your reply....:)
-
These two examples which you had mention I have gone through tjem but they are expalined for just how to make a qlist flickable...am i right here?
I am not using any of it...I will show you one of my screen's code:
DMMMenu.h:
@
#ifndef DMMMenu_H
#define DMMMenu_H
#include <QtGui>
#include <QWidget>
#include "../../DMM/Include/Voltage.h"
#include "../../DMM/Include/Current.h"
#include "../../DMM/Include/Resistance.h"
#include "../../DMM/Include/Memory.h"
namespace DMM
{
namespace Ui {
class DMMMenu;
}
class DMMMenu: public QWidget
{
Q_OBJECTpublic:
DMMMenu(QWidget *parent = 0);
~DMMMenu();public slots:
void OnVoltageClicked();
void OnCurrentClicked();
void OnResistanceClicked();
void OnMemoryClicked();
private:
Ui::DMMMenu *ui;public:
DMM::Voltage *voltage;
DMM::Current *current;
DMM::Resistance *resistance;
DMM::Memory *memory;
};}
#endif // DMMMenu_H
@
DMMMenu.cpp
@
#include "../../DMM/Include/DMMMenu.h"
#include "ui_DMMMenu.h"
#include <QDateTime>namespace DMM
{DMMMenu::DMMMenu(QWidget *parent) :
QWidget(parent),ui (new Ui::DMMMenu)
{
ui->setupUi(this);
voltage=new Voltage();
voltage->HO = this;
voltage->hide();current=new Current();
current->current_home =this;
current->hide();resistance=new Resistance ();
resistance->resistance_home=this;
resistance->hide();memory=new Memory ();
memory->Memory_home=this;
memory->hide();connect(ui->voltage_Button, SIGNAL(clicked()), this, SLOT(OnVoltageClicked()));
connect(ui->current_Button, SIGNAL(clicked()), this, SLOT(OnCurrentClicked()));
connect(ui->resistance_Button, SIGNAL(clicked()), this, SLOT(OnResistanceClicked()));
connect(ui->memory_Button, SIGNAL(clicked()), this, SLOT(OnMemoryClicked()));//get current date
QDate date = QDate::currentDate();
QString dateString = date.toString();
ui->Label_Date->setText(dateString);// get current time
QTime time = QTime::currentTime();
QString timeString = time.toString();
ui->Label_Time->setText(timeString);}
void DMMMenu::OnVoltageClicked()
{
voltage->show();
this->hide();
}void DMMMenu::OnCurrentClicked()
{
current->show();
this->hide();
}void DMMMenu::OnResistanceClicked()
{
resistance->show();
this->hide();
}void DMMMenu::OnMemoryClicked()
{
memory->show();
this->hide();
}DMMMenu::~DMMMenu()
{}
}
@
-
Yes, both solutions can be used to make lists flickable. Take a look at "QT-BUG9054":https://bugreports.qt-project.org/browse/QTBUG-9054 as well.
If Qt5 is an option for you take a look at "QScroller":http://doc-snapshot.qt-project.org/5.0/qscroller.html#details.
-
Okay ....thanks...will come back to you after going through these two links.....
:)
-
Is Flickable scroll of widget is supported in Qt 4.0?
-
Hope this will help you
doc.qt.nokia.com/4.7-snapshot/demos-embedded-flickable-flickable-cpp.html -
Hi all,
I followed exactly as explained in this link
http://qt-project.org/forums/viewthread/4059Used the same qskinecticscroller.h and .cpp files but still my code is working not I am not able to scroll it......Is there any changes I have to make in theqs kinecticscroller files?
here is my .cpp file in which setupUi is mentioned
@
#include <QtGui>
#include "kinectic.h"
#include "ui_kinectic.h"
#include "QDateTime"
#include "scroller.h"kinectic::kinectic(QWidget *parent) :
QWidget(parent),
ui(new Ui::kinectic)
{
ui->setupUi(this);scroller = new Scroller(this);
scroller->enableKineticScrollFor(ui->scrollArea);// // get current date
// QDate date = QDate::currentDate();
// QString dateString = date.toString();
// ui->label_date->setText(dateString);// // get current time
// QTime time = QTime::currentTime();
// QString timeString = time.toString();
// ui->label_time->setText(timeString);
}kinectic::~kinectic()
{
delete ui;
}@
Include file for the same:
@
#ifndef KINECTIC_H
#define KINECTIC_H#include "scroller.h"
#include <QWidget>
class Scroller;
namespace Ui {
class kinectic;
}class kinectic : public QWidget
{
Q_OBJECTpublic:
explicit kinectic(QWidget *parent = 0);
~kinectic();private:
Ui::kinectic ui;
Scrollerscroller;
};#endif // KINECTIC_H
@
-
Please reply!!!!