PyQt打开另一个窗口

时间:2018-03-21 10:56:40

标签: python pyqt window

当用户点击def start(self): window = MainWindow(self) window.show() self.hide() 并隐藏当前窗口时,我向用户显示了另一个窗口。但是当我隐藏当前窗口时,任务栏中没有应用程序图标。我怎么能做我想做的事? 我想显示新窗口并隐藏当前,但任务栏中的图标未显示。

public class MainActivity extends AppCompatActivity {
    LayoutInflater inflater;
    EditText mUsername;
    EditText mPassword;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button b = (Button)findViewById(R.id.button);

        inflater = MainActivity.this.getLayoutInflater();

        b.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                v = inflater.inflate(R.layout.dialog_login, null);
                AlertDialog.Builder mBuilder = new AlertDialog.Builder(MainActivity.this);
                mBuilder.setView(v);

                mUsername = (EditText)findViewById(R.id.username);
                mPassword = (EditText)findViewById(R.id.password);

                mBuilder.setPositiveButton("Login", new DialogInterface.OnClickListener()
                {
                    @Override
                    public void onClick(DialogInterface dialog, int id)
                    {
                        try
                        {   String username = mUsername.getText().toString();   }
                        catch(Exception e)
                        {   Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();  }
                    }
                });

                mBuilder.show();
            }
        });
    }
}

1 个答案:

答案 0 :(得分:1)

在self.hide()和self.showMinimized()

之间切换
def start(self):
    window = MainWindow(self)
    window.show()
    self.showMinimized()