Results 1 to 6 of 6

Thread: About Flick Charm

  1. #1
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default About Flick Charm

    Hello Everyone,

    I am new here and started QT just two months ago.

    The application that I have to develop need move 10 items up and down so I use flickcharm. It works well but my issue is that when that widget first loads. it first show the items in middle. I need to show the item on the top when that widget first loads. So where do I have to motify? I did add some code in main() but I didn't do anything. so anyone tell me how to do that?

    Thanks in advance

    For more information about how I used the flickcharm:
    When I used the flickcharm, I did write the code exactly like the colored example one in the flickcharm. But I didn't need to use QWebView library so I earsed the QWebView portion in flickcharm.cpp

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: About Flick Charm

    You need to give a lot more information for such a specific question.
    Post your code please.

  3. #3
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: About Flick Charm

    sorry....here my code

    Qt Code:
    1. /////////////////////////////InfoBox.cpp///////////////////////////
    2.  
    3. #include "infobox.h"
    4.  
    5. InfoBox::InfoBox(QWidget *parent)
    6. {
    7. int w = 640;// - height
    8. int h = 480;// - width
    9.  
    10. this->setFixedSize(h,150);
    11. this->setStyleSheet("background-color: black; color: white; border: 1px solid white;");
    12.  
    13. lblImage_.setFixedSize(80,100);
    14. lblTitle_.setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
    15. lblDuration_.setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
    16.  
    17. lblImage_.setAlignment(Qt::AlignTop);
    18.  
    19. lblTitle_.setText("Title Name");
    20. lblImage_.setText("");
    21. lblDuration_.setText("100 mins");
    22.  
    23. lblImage_.setStyleSheet("background-color: Blue; color: white; border-radius: 4px; border: 0px solid none;");
    24. lblTitle_.setStyleSheet("background-color: black; color: white; border: 0px solid none;");
    25. lblDuration_.setStyleSheet("background-color: black; color: white; border: 0px solid none;");
    26.  
    27. QVBoxLayout *lytInfo_ = new QVBoxLayout;
    28. lytInfo_->addWidget(&lblTitle_);
    29. lytInfo_->addWidget(&lblDuration_);
    30.  
    31. QHBoxLayout *lytMain_ = new QHBoxLayout;
    32. lytMain_->addWidget(&lblImage_);
    33. lytMain_->addSpacing(5);
    34. lytMain_->addLayout(lytInfo_);
    35.  
    36. this->setLayout(lytMain_);
    37. }
    38.  
    39. InfoBox::~InfoBox()
    40. {
    41.  
    42. }
    43.  
    44. ////////////////////////////////////////////////////////////////////
    45.  
    46. ////////////////////InfoBox.h///////////////////////////////////
    47.  
    48. #ifndef INFOBOX_H
    49. #define INFOBOX_H
    50.  
    51. #include <QWidget>
    52. #include <QObject>
    53. #include <QLabel>
    54. #include <QHBoxLayout>
    55. #include <QVBoxLayout>
    56.  
    57.  
    58. class InfoBox : public QWidget
    59. {
    60. public:
    61. explicit InfoBox(QWidget *parent=0);
    62. virtual ~InfoBox();
    63.  
    64. private:
    65.  
    66. QLabel lblTitle_;
    67. QLabel lblImage_;
    68. QLabel lblDuration_;
    69.  
    70. };
    71.  
    72. #endif // INFOBOX_H
    73.  
    74. /////////////////////////////////////////////////////////////////
    75.  
    76. /////////////////////InfoFlicker.cpp////////////////////////////
    77.  
    78. #include "infoflicker.h"
    79.  
    80. InfoFlicker::InfoFlicker(QWidget *parent)
    81. {
    82.  
    83. scene = new QGraphicsScene;
    84. scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    85. int w = 640;// - height
    86. int h = 480;// - width
    87.  
    88. QWidget *pFlicker = new QWidget(this);
    89.  
    90. int iPosY = 0;
    91.  
    92. for (int i = 0; i < 10 ; ++i) {
    93.  
    94. pInfoBox_= new InfoBox();
    95. pInfoBox_->resize(h, 150);
    96. proxy = new QGraphicsProxyWidget;
    97. proxy->setWidget(pInfoBox_);
    98. scene->addItem(proxy);
    99. proxy->setPos(0, iPosY);
    100. proxy->resize(h, 150);
    101. iPosY += 150;
    102. }
    103.  
    104. scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex);
    105.  
    106. canvas = new QGraphicsView(pFlicker);
    107. canvas->setScene(scene);
    108. canvas->setRenderHints(QPainter::TextAntialiasing);
    109. canvas->setFrameShape(QFrame::NoFrame);
    110. canvas->setFixedHeight(w);
    111. canvas->show();
    112.  
    113. pFlicker->show();
    114.  
    115. flick= new FlickCharm;
    116. flick->activateOn(canvas);
    117. }
    118.  
    119. InfoFlicker::~InfoFlicker()
    120. {
    121.  
    122. }
    123.  
    124.  
    125. ////////////////////////////////////////////////////////////////
    126.  
    127. ////////////////////////InfoFlicker.h/////////////////////////
    128.  
    129. #ifndef INFOFLICKER_H
    130. #define INFOFLICKER_H
    131.  
    132. #include <QObject>
    133. #include <QWidget>
    134. #include <QList>
    135. #include <QGraphicsScene>
    136. #include <QGraphicsView>
    137. #include <QGraphicsProxyWidget>
    138. #include <flickcharm.h>
    139. #include <infobox.h>
    140.  
    141. class InfoFlicker : public QWidget
    142. {
    143. public:
    144. explicit InfoFlicker(QWidget *parent=0);
    145. virtual ~InfoFlicker();
    146.  
    147. private:
    148. QWidget *pInfoBoxHolder_;
    149. InfoBox *pInfoBox_;
    150. QGraphicsView *canvas;
    151. QGraphicsProxyWidget *proxy;
    152.  
    153. FlickCharm *flick;
    154. };
    155.  
    156. #endif // INFOFLICKER_H
    157.  
    158. //////////////////////////////////////////////////////////////
    To copy to clipboard, switch view to plain text mode 


    for the FlickCharm, I used the code I found from this link http://qt.gitorious.org/qt-labs/grap...8f3/flickcharm

  4. #4
    Join Date
    May 2010
    Posts
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: About Flick Charm

    hey...i solved my problem.
    i wrote the follwing function in flickcharm.cpp

    Qt Code:
    1. void FlickCharm::moveToTop(QWidget *widget)
    2. {
    3. QAbstractScrollArea *scrollArea = dynamic_cast<QAbstractScrollArea*>(widget);
    4. if (scrollArea)
    5. {
    6.  
    7. QWidget *viewport = scrollArea->viewport();
    8. FlickData *data = d->flickData.value(viewport);
    9.  
    10. QPoint topLeft = viewport->rect().topLeft();
    11.  
    12. setScrollOffset(data->widget,topLeft);
    13. data->state = FlickData::Steady;
    14.  
    15. widget->update();
    16. viewport->update();
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    And I called this funtion from InfoFlicker.cpp.
    But it won't work properly when the infobox list is called for the first time. It will work next time when u update the infobox list.
    I still don't know why this happen

  5. #5
    Join Date
    Jul 2010
    Location
    jammu and kashmir , india
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About Flick Charm

    i really hope that it will work...

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: About Flick Charm

    I guess the flickcharm example internallly uses QSlider for the sliding..
    so why dont you set the value of QSlider simply to 0...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.