Russian Qt Forum
Мая 04, 2025, 12:03 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: [1]   Вниз
  Печать  
Автор Тема: Возможно ли QProcessDialog использовать без таймера?  (Прочитано 5136 раз)
fear
Гость
« : Сентября 07, 2006, 17:29 »

Пробовал вот такой вариант. ProcessBar нормально работает, а кнопку "cancel" нажать невозможно.

Код:
void func()
{
  int counter = 0;
  QProgressDialog dialog;

  dialog.setValue(counter);
  dialog.show();

  for(int i=1; i<=100; i++)
  {
    //// Чтение из устройства

    dialog.setValue(i);
    if(dialog.wasCanceled()) return;
  }
}
Записан
BaltikS
Гость
« Ответ #1 : Сентября 07, 2006, 17:46 »

Всё просто поставь в цикле qApp->processEvents()
Записан
Admin
Administrator
Джедай : наставник для всех
*****
Offline Offline

Сообщений: 1988



Просмотр профиля
« Ответ #2 : Сентября 07, 2006, 18:08 »

если чтение из устройство идет долго то только QThread тебе поможет
Записан
fear
Гость
« Ответ #3 : Сентября 08, 2006, 16:47 »

Спасибо за помошь, обошёлся qApp->processEvents().
Записан
kolob
Частый гость
***
Offline Offline

Сообщений: 296



Просмотр профиля
« Ответ #4 : Ноября 26, 2010, 17:49 »

Подскажите, а кнопку cancel вообще можно убрать из QProcessDialog?
Записан

Qt 5.11.0, Win, MinGW
White Owl
Гость
« Ответ #5 : Декабря 03, 2010, 21:22 »

Да, конечно.

Цитировать
QProgressDialog::QProgressDialog ( const QString & labelText, const QString & cancelButtonText, int minimum, int maximum, QWidget * parent = 0, Qt::WindowFlags f = 0 )
Constructs a progress dialog.

The labelText is the text used to remind the user what is progressing.

The cancelButtonText is the text to display on the cancel button. If QString() is passed then no cancel button is shown.

The minimum and maximum is the number of steps in the operation for which this progress dialog shows progress. For example, if the operation is to examine 50 files, this value minimum value would be 0, and the maximum would be 50. Before examining the first file, call setValue(0). As each file is processed call setValue(1), setValue(2), etc., finally calling setValue(50) after examining the last file.

The parent argument is the dialog's parent widget. The parent, parent, and widget flags, f, are passed to the QDialog::QDialog() constructor.

See also setLabelText(), setLabel(), setCancelButtonText(), setCancelButton(), setMinimum(), and setMaximum().
Записан
kolob
Частый гость
***
Offline Offline

Сообщений: 296



Просмотр профиля
« Ответ #6 : Декабря 04, 2010, 01:07 »

White Owl, спасибо. Буду знать. А то пришлось самому делать из QProgressBar.
Записан

Qt 5.11.0, Win, MinGW
Страниц: [1]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.023 секунд. Запросов: 19.