Simulation QQ System Setup Panel implementation function

Source: Internet
Author: User

Business requirements:

Based on the implementation of the network disk client, the Setup Panel of the original network disk can not meet our normal demand either from the interface display or from the business requirement. The current requirement is that the panel that simulates the QQ system Setup realizes the basic configuration function of the current network disk. In completing this article, the basic performance has been completed, although not integrated into the network disk client, but the fundamental technology Preview has been implemented.

QQ System Setup Panel analysis:

QQ System Setup Panel:

QQ System Setup Panel function Description:

Because there are more configurations, if each module's configuration items are designed into a form, there are a lot of forms that don't fit the user experience, and the program is cumbersome to write. The implementation of the QQ System Setup Panel is that all the configuration items are listed in the right area, and when the scroll bar is moved to the right, the corresponding caption in the left navigation will also show the effect of clicking. At the same time, click on the left side of the navigation separately, the right area also shows the corresponding navigation configuration items.

Implementation ideas:

Left:

The implementation of the left-hand navigation is very simple, the use of qlistwidget can fully meet our needs, as far as the left side of the right to display the corresponding module configuration items will require us to add processing code completion.

Right:

Because the navigation bar exists on the right side, the area on the right needs to use the Qscrollarea control, where it is important to note that two points:1> the configuration of each module in the Qscrollarea control needs to be placed in a separate qwidget, only So we can only recognize when we move the scroll bar through a block of configuration items. 2> in the implementation of the scroll bar effect, see there are many articles on the web that the scroll bar effect can not be realized, in fact, my practice is very simple, in the UI form, drag Qscrollarea into the form, and then set the properties of the form: Widgetresizable is not selected, that is, false status. If your qscrollarea is new in the code, its default widgetresizable is true, and it must be set to False in the code.

To visually illustrate the first point of attention, multiple qwidget (one qwidget per module configuration) are prevented in the Qscrollarea area of the UI form that I tested, with the following map:

The problem we are facing here is:

1. How do I decide to pass a qwidget when I drag the scrollbar to show the corresponding item on the left?

First, the ValueChanged event of the vertical scrollbar needs to be bound so that we can monitor its movement changes at any time, and secondly, using Qwidget's Visibleregion () method, the official interpretation of this function is " When the Paint event appears, return to its clear range, and to the visible widget, it is an approximate range that is not covered by other widgets; Returns an empty range "by calling Qwidget's Visibleregion (). IsEmpty () You can identify the area that is currently sliding.

2. When you click on the left navigation, how do the right areas navigate to the corresponding configuration module?

First, you need to bind the Qlistwidget itemclicked event so that we can monitor the click event and then use the Qscrollbar setsliderposition () method to set the scroll to the specific module location.

3. Because the ValueChanged event of the ScrollBar is bound and the scrollbar is set in the Itemclicked event, does the ValueChanged event also be triggered while setting the position?

A variable is required to mark this valuechanged event due to the Setsliderposition method.

Key Code Snippet:

1. Binding Qscrollarea valuechanged Events and Qlistwidget itemclicked events

[CPP]View PlainCopy 
  1. void Lhtsettingsboard::setupui ()
  2. {
  3. M_scroll = Qfindchild<qscrollarea *> (m_wgtmain, "Scrollarea");
  4. M_widget_login = Qfindchild<qwidget *> (m_wgtmain, "Widget_login");
  5. M_widget_register = Qfindchild<qwidget *> (m_wgtmain, "Widget_register");
  6. M_widget_network = Qfindchild<qwidget *> (m_wgtmain, "widget_network");
  7. M_widget_password = Qfindchild<qwidget *> (m_wgtmain, "Widget_password");
  8. M_listwidget = Qfindchild<qlistwidget *> (m_wgtmain, "left_navigation");
  9. Connect ((const qobject*) M_scroll->verticalscrollbar (), SIGNAL (valuechanged (int)), this , SLOT (  valuechanged (int)));
  10. Connect (M_listwidget, SIGNAL (itemclicked (qlistwidgetitem*)), this , SLOT (itemclicked (qlistwidgetitem*)));
  11. Qlistwidgetitem *loginitem = m_listwidget->item (0);
  12. Loginitem->setselected (true);
  13. M_wgtmain->show ();
  14. }

2. In response to the slot of the ValueChanged event, when the scroll bar is complete, the selected event of item in the left Qlistwidget is triggered when a panel appears

[CPP]View PlainCopy 
  1. void lhtsettingsboard::valuechanged (int value)
  2. {
  3. Qlistwidgetitem *loginitem = m_listwidget->item (0);
  4. Qlistwidgetitem *registeritem = M_listwidget->item (1);
  5. Qlistwidgetitem *networkitem = M_listwidget->item (2);
  6. Qlistwidgetitem *passworditem = M_listwidget->item (3);
  7. if (!m_sign)
  8. {
  9. if (!m_widget_login->visibleregion (). IsEmpty ())
  10. {
  11. Loginitem->setselected (true);
  12. return;
  13. }
  14. Else
  15. {
  16. Loginitem->setselected (false);
  17. }
  18. if (!m_widget_register->visibleregion (). IsEmpty ())
  19. {
  20. Registeritem->setselected (true);
  21. return;
  22. }
  23. Else
  24. {
  25. Registeritem->setselected (false);
  26. }
  27. if (!m_widget_network->visibleregion (). IsEmpty ())
  28. {
  29. Networkitem->setselected (true);
  30. return;
  31. }
  32. Else
  33. {
  34. Networkitem->setselected (false);
  35. }
  36. if (!m_widget_password->visibleregion (). IsEmpty ())
  37. {
  38. Passworditem->setselected (true);
  39. return;
  40. }
  41. Else
  42. {
  43. Passworditem->setselected (false);
  44. }
  45. }
  46. M_sign = false;
  47. }

3. In response to the slot of the itemclicked event, when you finish clicking Item in Qlistwidget, the scroll bar in Qscrollarea moves to the location of the corresponding configuration item

[CPP]View PlainCopy 
  1. void lhtsettingsboard::itemclicked (Qlistwidgetitem *item)
  2. {
  3. QString Itemtext = Item->text ();
  4. Qdebug () << itemtext;
  5. Qpoint POS;
  6. M_sign = true;
  7. if (Itemtext.compare ("Login") = = 0)
  8. {
  9. pos = M_widget_login->pos ();
  10. M_scroll->verticalscrollbar ()->setsliderposition (Pos.y ());
  11. }
  12. Else if (Itemtext.compare ("Register") = = 0)
  13. {
  14. pos = M_widget_register->pos ();
  15. M_scroll->verticalscrollbar ()->setsliderposition (Pos.y ());
  16. }
  17. Else if (Itemtext.compare ("Network") = = 0)
  18. {
  19. pos = M_widget_network->pos ();
  20. M_scroll->verticalscrollbar ()->setsliderposition (Pos.y ());
  21. }
  22. Else if (Itemtext.compare ("ChangePassword") = = 0)
  23. {
  24. pos = M_widget_password->pos ();
  25. M_scroll->verticalscrollbar ()->setsliderposition (Pos.y ());
  26. }
  27. }

Summarize:

Through the above can be implemented similar to the QQ System Setup Panel function, beginning I to this piece how to achieve, use what control completely do not know, spend less than a day of the event search data, test to find the appropriate method. In the process of deep experience to solve the problem is the most critical place is the idea, if there is a train of thought, even if others tell you should go in which direction, the back of the work is actually very simple. Enjoy the process slowly, a problem by completely do not know how to solve, to have ideas, to really solve.

http://blog.csdn.net/houqd2012/article/details/26501791

Simulation QQ System Setup Panel implementation function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.