带滑块的Qt Widget

时间:2015-04-29 14:58:23

标签: python qt pyqt

我正在使用PyQt4编写GUI应用程序,我需要创建可以垂直滑动的小部件和对话框窗口。单击“添加新窗口小部件”按钮(并向下移动)后,我创建了动态新的小窗口小部件(包含2个public View getView(final int position, View convertView, ViewGroup parent) { if (layoutInflater == null) { layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } if (convertView == null) { convertView = layoutInflater.inflate(R.layout.list_item_thought, null); } thoughtText = (TextView) convertView.findViewById(R.id.thought_text_view); likeButton = (Button) convertView.findViewById(R.id.thought_like_button); dislikeButton = (Button) convertView.findViewById(R.id.thought_dislike_button); //thoughtItems is a list of custom ojbects (Thought) Thought t = thoughtItems.get(position); //Here i set the content of the current TextView thoughtText.setText(t.getText()); //the two buttons do basically the same thing when get clicked likeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Thought t = thoughtItems.get(position); thoughtId = t.getId(); opinion = 1; AsyncPost asyncPost = new AsyncPost(activity,ThoughtListAdapter.this); asyncPost.execute(SHARE_THOUGHT_URL, TAG_PERSON_EMAIL, "m@b.it", TAG_THOUGHT_ID, thoughtId.toString(), TAG_OPINION, opinion.toString()); } }); dislikeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Thought t = thoughtItems.get(position); thoughtId = t.getId(); opinion = 0; AsyncPost asyncPost = new AsyncPost(activity,ThoughtListAdapter.this); asyncPost.execute(SHARE_THOUGHT_URL, TAG_PERSON_EMAIL, "m@b.it", TAG_THOUGHT_ID, thoughtId.toString(), TAG_OPINION, opinion.toString()); } }); return convertView; } @Override public void onComplete(JSONObject json) { if (json != null) { try { if (json.getInt(TAG_SUCCESS) == 0) { Toast.makeText(activity, "Operazione non riuscita.", Toast.LENGTH_LONG).show(); } else { //if everything is good i try to make the buttons of that particular list item disappear likeButton.setVisibility(View.GONE); dislikeButton.setVisibility(View.GONE); } } catch (JSONException e) { Log.e(TAG_LOG, "JSONException", e); } } else Toast.makeText(activity, "Errore connessione!", Toast.LENGTH_LONG).show(); } 个对象)。我想避免当窗口的高度太小而无法正确显示所有小部件时的情况,因此显而易见的解决方案似乎是一个滑块。我尝试使用textEdit,但我不确定这是否是最佳方式以及如何配置此类滑块。

QSlider

enter image description here

0 个答案:

没有答案