Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QStateMachine and dependent properties
Forum Updated to NodeBB v4.3 + New Features

QStateMachine and dependent properties

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 833 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    setting states
    @
    state_downloading_ = new QState(&state_machine_);
    state_downloading_->assignProperty(download_button_, "enabled", false);

    state_download_finished_ = new QState(state_machine_);
    state_download_finished_->assignProperty(download_button_, "enabled", true);

    state_general_ = new QState(&state_machine_);
    state_general_->assignProperty(download_button_, "enabled", true);

    state_loading_theme_ = new QState(&state_machine);
    state_loading_theme_->assignProperty(download_button_, "enabled", false);
    @

    setting transition
    @
    state_downloading_->addTransition(this, SIGNAL(download_finish()), state_download_finish_);
    state_download_finished_->addTransition(loading_button_, SIGNAL(clicked()), state_loading_theme_);

    state_general_->addTransition(download_button_, SIGNAL(clicked()), state_downloading_);
    state_general_->addTransition(loading_button_, SIGNAL(clicked()), state_loading_theme_);

    state_loading_theme_->addTransition(this, SIGNAL(loading_finish()), state_general_);
    @

    The problem is, these states are asynchronous and the properties of
    the download button is dependent on the states
    That means something like

    state_downloading_->disabled button->state_download_finished_->button_enabled
    state_loading_theme_->disabled button--------------------------->still downloading and the button should be disabled

    I could solve this by mutex and without setting the property of the button by assignProperty
    But this is ugly, do I have better choices?Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved