简体   繁体   English

Qt中的用户系统

[英]User system in Qt

I'm building an app that will run on our network for job tracking with two user levels, one for general users and one for administrators. 我正在构建一个将在我们的网络上运行的应用程序,该应用程序具有两个用户级别,一个用于一般用户,一个用于管理员。

How are user systems usually implemented in Qt? 通常在Qt中如何实现用户系统? For example, how are user state and user roles handled? 例如,如何处理用户状态和用户角色? Should I just include a C++ class and set these types of things as properties within that class, or are there established and well documented "best practices" for implementing user systems within Qt? 我应该只包含一个C ++类并将这些类型的事物设置为该类中的属性,还是应该在Qt中建立并记录良好的“最佳实践”来实现用户系统?

I also need to be able to share user state and role among various classes. 我还需要能够在各个类之间共享用户状态和角色。 For example, the menu class needs to know the user state & role to know what items to display. 例如,菜单类需要知道用户状态和角色才能知道要显示哪些项目。

Any help is appreciated! 任何帮助表示赞赏!

What you are asking for doesn't make sense in terms of Qt on it's own. 就Qt本身而言,您要的内容没有任何意义。 Qt is a framework for local client apps. Qt是本地客户端应用程序的框架。 The Qt application displays it's information to only 1 user at a time on one display / desktop at a time. Qt应用程序一次仅在一台显示器/台式机上仅向1个用户显示其信息。

You framed the question in terms of a networked job tracking application. 您是根据网络作业跟踪应用程序来构造问题的。 Lets assume this implies there is some sort of job tracking server. 让我们假设这意味着存在某种作业跟踪服务器。 Likewise, let's assume you are writing a client for this server application in Qt. 同样,假设您正在Qt中为此服务器应用程序编写客户端。 In this model you could let the Qt application login to the server using credentials provided by the user. 在此模型中,您可以使用用户提供的凭据让Qt应用程序登录到服务器。 Then it would be the server's job to tell you whether the user is who they claim to be and what role they have and to enforce any security restrictions. 然后,服务器的工作就是告诉您用户是否是他们声称的身份以及他们所扮演的角色,并强制执行任何安全性限制。

Since you say you are familiar with web applications, lets draw an analogy. 既然您说您对Web应用程序很熟悉,那么让我们作一个类比。 Qt is intended to provide you the tools to write the web browser only; Qt旨在为您提供仅编写Web浏览器的工具; you would still need to provide the the web server and web application to run within it. 您仍然需要提供Web服务器和Web应用程序才能在其中运行。 Thus 从而

Qt application is to web browser as X is to web server. 

You have to provide "X", and that is where you implement the user system. 您必须提供“ X”,这就是实现用户系统的地方。

Of course Qt does provide basic support stuff like network sockets, but on it's own I don't think it's well suited to writing a server application. 当然,Qt确实提供了诸如网络套接字之类的基本支持,但是就我个人而言,它并不适合编写服务器应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM