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. QTreeWidget how to output selected item name.. ?

QTreeWidget how to output selected item name.. ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 726 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.
  • L Offline
    L Offline
    lukutis222
    wrote on last edited by
    #1

    Hello. I have recently started getting into QT and Widgets. I have designed a UI table using QT Creator design option. I have also made a slots fr my TreeWidgets that I want to select. I did not implement any of the code myself, once I select which slot I want to, the code is being generated outside my project directory and wont let me access and see any of it.
    The slot that I have created is on_projectTreeWidget_itemPressed ( See the picture below)
    https://ibb.co/QDmyN0z
    It also generated a function in my mainwindow:
    void MainWindow::on_projectTreeWidget_itemPressed(QTreeWidgetItem *item, int column)
    {
    qDebug()<<"item"<<item<<endl;
    qDebug()<<"column"<<column<<endl;
    qDebug()<<"&item"<<&item<<endl;

    }
    I am trying to debug print a name of selected widget for example(test_main_script) but it just return some random characters and I dont know what wrong I am doing?? Can someone give me some advice please

    VRoninV 1 Reply Last reply
    0
    • Himanshu chardeH Offline
      Himanshu chardeH Offline
      Himanshu charde
      wrote on last edited by Himanshu charde
      #2

      int row = 0;//test_main_script data row
      qDebug()<<ui->Tablewidget->selectedItems().at(row)->data(col).toString();

      1 Reply Last reply
      0
      • L lukutis222

        Hello. I have recently started getting into QT and Widgets. I have designed a UI table using QT Creator design option. I have also made a slots fr my TreeWidgets that I want to select. I did not implement any of the code myself, once I select which slot I want to, the code is being generated outside my project directory and wont let me access and see any of it.
        The slot that I have created is on_projectTreeWidget_itemPressed ( See the picture below)
        https://ibb.co/QDmyN0z
        It also generated a function in my mainwindow:
        void MainWindow::on_projectTreeWidget_itemPressed(QTreeWidgetItem *item, int column)
        {
        qDebug()<<"item"<<item<<endl;
        qDebug()<<"column"<<column<<endl;
        qDebug()<<"&item"<<&item<<endl;

        }
        I am trying to debug print a name of selected widget for example(test_main_script) but it just return some random characters and I dont know what wrong I am doing?? Can someone give me some advice please

        VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        @lukutis222 said in QTreeWidget how to output selected item name.. ?:

        &item

        This is of type QTreeWidgetItem **item probably not what you want. I'd guess you were looking for item->text() instead

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2

        • Login

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