Results 1 to 4 of 4

Thread: how to implement it ?

  1. #1
    Join Date
    Oct 2006
    Posts
    15
    Qt products

    Default how to implement it ?

    hi, all

    i want to implement a widget like the following, which is like a Qtabbar:

    ________________
    |_5_|_6_|_7_|_8_| |>

    the left and right are two toolbuttons(i cannot draw the left button). in the middle are 4 horizontal grid to show 4 texts.

    if the left toolbutton is pressed, the middle will show the previous 4 texts before the current leftmost text such as 1,2,3 and 4. if the right toolbutton is pressed, the middle will show the next 4 texts after the current rightmost text such as 9,10,11 and 12.

    and the count of the texts can be specified.

    any help is appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to implement it ?

    Depends if you need those button to be tabs or not. If not, then this should be very easy. Create six buttons and place them in a horizontal layout (you can use a button group to ease your job). The rightmost and leftmost buttons will be used to do the "scrolling" - connect their clicked() signal to a custom slot and in the slot modify the range of numbers displayed. Then connect the button group's clicked() signal to a custom slot and in that slot emit a custom signal with the number of the button clicked (mapped according to the range), for example:
    Qt Code:
    1. /**
    2.  * connected to QButtonGroup::clicked(int)
    3.  */
    4. void wgt::clickedSlot(int c){
    5. emit activated(c+leftmostid);
    6. }
    7.  
    8. /**
    9.  * connected to scroller's clicked()
    10.  */
    11. void wgt::scrollerClicked(){
    12. leftmostid+=sender()==rightScrollButton ? 4 : -4;
    13. updateButtons();
    14. }
    15.  
    16. void wgt::updateButtons(){
    17. button1->setText(QString::number(leftmost));
    18. button2->setText(QString::number(leftmost+1));
    19. button3->setText(QString::number(leftmost+2));
    20. button4->setText(QString::number(leftmost+3));
    21. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Oct 2006
    Posts
    15
    Qt products

    Default Re: how to implement it ?

    wysota, thanks very much.

    I know what you mean.

    now what i want to do is to implement it as a widget such as QTabbar or QSpinBox, so that i can integrate it into Qt Designer and use it by applications conveniently.

    any suggestion about it ? thanks in advance.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to implement it ?

    Just wrap it into a QWidget and create a Designer plugin out of it.

Similar Threads

  1. Ideas about how to implement Undo and Redo actions?
    By pir in forum General Discussion
    Replies: 3
    Last Post: 21st July 2006, 09:27
  2. drag and drop
    By mickey in forum Qt Programming
    Replies: 5
    Last Post: 27th May 2006, 03:05
  3. Replies: 3
    Last Post: 12th May 2006, 19:31
  4. How should I implement hide-able UI elements ?
    By barnabyr in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2006, 08:09
  5. Implement Undo Redo
    By ankurjain in forum Qt Programming
    Replies: 5
    Last Post: 28th March 2006, 13:17

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.