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. QWidgetAction how to use properly?

QWidgetAction how to use properly?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qwidgetactionqactionqtoolbar
1 Posts 1 Posters 706 Views
  • 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 29 Jun 2018, 19:35 last edited by Dariusz
    #1

    Hello

    I'd like to create few widgets via QAction system so that they all share the given data.

    Say if I create a QLineEdit and then add that QAction to 3 toolbars. I'd like to upon pressing return to update all instances of that action.

    So if I build something like this for my QWidgetAction instance>

    QWidget *icActionLineEdit::createWidget(QWidget *parent) {
        QLineEdit *edit = new QLineEdit(parent);
        connect(edit, &QLineEdit::returnPressed, [=]() {
            mText = edit->text();
            emit triggered(true);
        });
        connect(this, &icActionLineEdit::triggered, [=]() { edit->setText(mText); });
        return edit;
    }
    

    This should update/sync the lineEdits when text is pressed?

    I'm not quite sure. As I don't know how I can add 2 QActions of the same action in 1+ toolbars.

    if I just do

    toolbar->addAction(actionLineEdit)
    toolbar->addAction(actionLineEdit)

    It only adds one of them... so I'm a tad lost & I cant really test the above test...

    Any hints how I can use that system? I want to sync line edits/radio buttons/etc/etc (I think QAction provide radio button via QActionGroup tho)

    Regards
    Dariusz
    TIA

    Also can I add that QWidgetAction in to normal layout by any chance? Seems like a a great way to synchronize widgets together if I want to show the same lineEdit in multiple areas in my app ?

    1 Reply Last reply
    0

    1/1

    29 Jun 2018, 19:35

    • Login

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